-
-
Notifications
You must be signed in to change notification settings - Fork 10.3k
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 longer paste from Windows 10 to Android 13 (QPR Beta 1) #3497
Comments
Please replace
diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index e25b6e99..b178d18d 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -18,6 +18,9 @@ public class ClipboardManager {
public ClipboardManager(IInterface manager) {
this.manager = manager;
+ for (Method m : manager.getClass().getDeclaredMethods()) {
+ Ln.i("=== " + m);
+ }
}
private Method getGetPrimaryClipMethod() throws NoSuchMethodException { |
|
OK, the function signature has changed on your device, but this does not match the AOSP source code on tag So they probably changed something whose source code is not published yet, so I don't know what is the meaning of this additional Let's try to pass the package name twice: diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index e25b6e99..916a690c 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -15,6 +15,8 @@ public class ClipboardManager {
private Method getPrimaryClipMethod;
private Method setPrimaryClipMethod;
private Method addPrimaryClipChangedListener;
+ private boolean alternativeGetMethod;
+ private boolean alternativeSetMethod;
public ClipboardManager(IInterface manager) {
this.manager = manager;
@@ -25,7 +27,12 @@ public class ClipboardManager {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class);
} else {
- getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
+ try {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class);
+ alternativeGetMethod = true;
+ }
}
}
return getPrimaryClipMethod;
@@ -36,23 +43,33 @@ public class ClipboardManager {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class);
} else {
- setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
+ try {
+ setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class);
+ alternativeSetMethod = true;
+ }
}
}
return setPrimaryClipMethod;
}
- private static ClipData getPrimaryClip(Method method, IInterface manager) throws InvocationTargetException, IllegalAccessException {
+ private static ClipData getPrimaryClip(Method method, boolean alternativeMethod, IInterface manager) throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME);
}
+ if (alternativeMethod) {
+ return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
+ }
return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
}
- private static void setPrimaryClip(Method method, IInterface manager, ClipData clipData)
+ private static void setPrimaryClip(Method method, boolean alternativeMethod, IInterface manager, ClipData clipData)
throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME);
+ } else if (alternativeMethod) {
+ method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
} else {
method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
}
@@ -61,7 +78,7 @@ public class ClipboardManager {
public CharSequence getText() {
try {
Method method = getGetPrimaryClipMethod();
- ClipData clipData = getPrimaryClip(method, manager);
+ ClipData clipData = getPrimaryClip(method, alternativeGetMethod, manager);
if (clipData == null || clipData.getItemCount() == 0) {
return null;
}
@@ -76,7 +93,7 @@ public class ClipboardManager {
try {
Method method = getSetPrimaryClipMethod();
ClipData clipData = ClipData.newPlainText(null, text);
- setPrimaryClip(method, manager, clipData);
+ setPrimaryClip(method, alternativeSetMethod, manager, clipData);
return true;
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e);
|
It works again! The console output still shows an error, but i don't know if that's important;
|
Oh, they also added a
Yes, it's to synchronize the clipboard from Android to the computer. Here is a version with a fix for this method too: diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index e25b6e99..bfed7442 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -15,6 +15,9 @@ public class ClipboardManager {
private Method getPrimaryClipMethod;
private Method setPrimaryClipMethod;
private Method addPrimaryClipChangedListener;
+ private boolean alternativeGetMethod;
+ private boolean alternativeSetMethod;
+ private boolean alternativeAddListenerMethod;
public ClipboardManager(IInterface manager) {
this.manager = manager;
@@ -25,7 +28,12 @@ public class ClipboardManager {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class);
} else {
- getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
+ try {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class);
+ alternativeGetMethod = true;
+ }
}
}
return getPrimaryClipMethod;
@@ -36,23 +44,34 @@ public class ClipboardManager {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class);
} else {
- setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
+ try {
+ setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class);
+ alternativeSetMethod = true;
+ }
}
}
return setPrimaryClipMethod;
}
- private static ClipData getPrimaryClip(Method method, IInterface manager) throws InvocationTargetException, IllegalAccessException {
+ private static ClipData getPrimaryClip(Method method, boolean alternativeMethod, IInterface manager)
+ throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME);
}
+ if (alternativeMethod) {
+ return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
+ }
return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
}
- private static void setPrimaryClip(Method method, IInterface manager, ClipData clipData)
+ private static void setPrimaryClip(Method method, boolean alternativeMethod, IInterface manager, ClipData clipData)
throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME);
+ } else if (alternativeMethod) {
+ method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
} else {
method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
}
@@ -61,7 +80,7 @@ public class ClipboardManager {
public CharSequence getText() {
try {
Method method = getGetPrimaryClipMethod();
- ClipData clipData = getPrimaryClip(method, manager);
+ ClipData clipData = getPrimaryClip(method, alternativeGetMethod, manager);
if (clipData == null || clipData.getItemCount() == 0) {
return null;
}
@@ -76,7 +95,7 @@ public class ClipboardManager {
try {
Method method = getSetPrimaryClipMethod();
ClipData clipData = ClipData.newPlainText(null, text);
- setPrimaryClip(method, manager, clipData);
+ setPrimaryClip(method, alternativeSetMethod, manager, clipData);
return true;
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e);
@@ -84,13 +103,14 @@ public class ClipboardManager {
}
}
- private static void addPrimaryClipChangedListener(Method method, IInterface manager, IOnPrimaryClipChangedListener listener)
- throws InvocationTargetException, IllegalAccessException {
+ private static void addPrimaryClipChangedListener(Method method, boolean alternativeMethod, IInterface manager,
+ IOnPrimaryClipChangedListener listener) throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
method.invoke(manager, listener, ServiceManager.PACKAGE_NAME);
- } else {
+ } else if (alternativeMethod) {
+ method.invoke(manager, listener, ServiceManager.PACKAGE_NAME, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
+ } else
method.invoke(manager, listener, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
- }
}
private Method getAddPrimaryClipChangedListener() throws NoSuchMethodException {
@@ -99,8 +119,14 @@ public class ClipboardManager {
addPrimaryClipChangedListener = manager.getClass()
.getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class);
} else {
- addPrimaryClipChangedListener = manager.getClass()
- .getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class, int.class);
+ try {
+ addPrimaryClipChangedListener = manager.getClass()
+ .getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ addPrimaryClipChangedListener = manager.getClass()
+ .getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class, String.class, int.class);
+ alternativeAddListenerMethod = true;
+ }
}
}
return addPrimaryClipChangedListener;
@@ -109,7 +135,7 @@ public class ClipboardManager {
public boolean addPrimaryClipChangedListener(IOnPrimaryClipChangedListener listener) {
try {
Method method = getAddPrimaryClipChangedListener();
- addPrimaryClipChangedListener(method, manager, listener);
+ addPrimaryClipChangedListener(method, alternativeAddListenerMethod, manager, listener);
return true;
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e);
|
Perfect fix! no error message. Thank you so much! |
Having this fixed is great, thx! However, I am not sure how I can access this fix without compiling the project myself. |
Just take this binary: #3497 (comment) and replace it in your v1.24 release. |
Thx, it works. |
Just FYI, alternatively, you could download it anywhere, and set the environment variable export SCRCPY_SERVER_PATH=/path/to/your/scrcpy-server |
Same issue here with Pixel 6 Pro. I don't work for Android team, but I may be running on an unreleased build. I got this issue after a security update, and it took some time to update, so I wonder if the changes were quite major. The date of the security update is a future time around early December 2022. I think that's all I can provide for now. :P Many thanks for your work including the fix in this thread, rom1v! |
Can we get this (or even better a true fix) as a proper release, please? makes installing and managing versions easier. |
That last binary, #3497 (comment), and
also worked for me, thanks! Only stopped working with the latest Android security patch: Phone: Pixel 4a Laptop: macOS Montery 12.6.1 |
They finally published the change in AOSP: 0e3e509b. A new parameter Please test this new binary and confirm that it works. diffdiff --git a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
index e25b6e99..aeb59357 100644
--- a/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
+++ b/server/src/main/java/com/genymobile/scrcpy/wrappers/ClipboardManager.java
@@ -15,6 +15,9 @@ public class ClipboardManager {
private Method getPrimaryClipMethod;
private Method setPrimaryClipMethod;
private Method addPrimaryClipChangedListener;
+ private boolean alternativeGetMethod;
+ private boolean alternativeSetMethod;
+ private boolean alternativeAddListenerMethod;
public ClipboardManager(IInterface manager) {
this.manager = manager;
@@ -25,7 +28,12 @@ public class ClipboardManager {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class);
} else {
- getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
+ try {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class);
+ alternativeGetMethod = true;
+ }
}
}
return getPrimaryClipMethod;
@@ -36,23 +44,34 @@ public class ClipboardManager {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class);
} else {
- setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
+ try {
+ setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class);
+ alternativeSetMethod = true;
+ }
}
}
return setPrimaryClipMethod;
}
- private static ClipData getPrimaryClip(Method method, IInterface manager) throws InvocationTargetException, IllegalAccessException {
+ private static ClipData getPrimaryClip(Method method, boolean alternativeMethod, IInterface manager)
+ throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME);
}
+ if (alternativeMethod) {
+ return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME, null, ServiceManager.USER_ID);
+ }
return (ClipData) method.invoke(manager, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
}
- private static void setPrimaryClip(Method method, IInterface manager, ClipData clipData)
+ private static void setPrimaryClip(Method method, boolean alternativeMethod, IInterface manager, ClipData clipData)
throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME);
+ } else if (alternativeMethod) {
+ method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME, null, ServiceManager.USER_ID);
} else {
method.invoke(manager, clipData, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
}
@@ -61,7 +80,7 @@ public class ClipboardManager {
public CharSequence getText() {
try {
Method method = getGetPrimaryClipMethod();
- ClipData clipData = getPrimaryClip(method, manager);
+ ClipData clipData = getPrimaryClip(method, alternativeGetMethod, manager);
if (clipData == null || clipData.getItemCount() == 0) {
return null;
}
@@ -76,7 +95,7 @@ public class ClipboardManager {
try {
Method method = getSetPrimaryClipMethod();
ClipData clipData = ClipData.newPlainText(null, text);
- setPrimaryClip(method, manager, clipData);
+ setPrimaryClip(method, alternativeSetMethod, manager, clipData);
return true;
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e);
@@ -84,13 +103,14 @@ public class ClipboardManager {
}
}
- private static void addPrimaryClipChangedListener(Method method, IInterface manager, IOnPrimaryClipChangedListener listener)
- throws InvocationTargetException, IllegalAccessException {
+ private static void addPrimaryClipChangedListener(Method method, boolean alternativeMethod, IInterface manager,
+ IOnPrimaryClipChangedListener listener) throws InvocationTargetException, IllegalAccessException {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
method.invoke(manager, listener, ServiceManager.PACKAGE_NAME);
- } else {
+ } else if (alternativeMethod) {
+ method.invoke(manager, listener, ServiceManager.PACKAGE_NAME, null, ServiceManager.USER_ID);
+ } else
method.invoke(manager, listener, ServiceManager.PACKAGE_NAME, ServiceManager.USER_ID);
- }
}
private Method getAddPrimaryClipChangedListener() throws NoSuchMethodException {
@@ -99,8 +119,14 @@ public class ClipboardManager {
addPrimaryClipChangedListener = manager.getClass()
.getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class);
} else {
- addPrimaryClipChangedListener = manager.getClass()
- .getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class, int.class);
+ try {
+ addPrimaryClipChangedListener = manager.getClass()
+ .getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class, int.class);
+ } catch (NoSuchMethodException e) {
+ addPrimaryClipChangedListener = manager.getClass()
+ .getMethod("addPrimaryClipChangedListener", IOnPrimaryClipChangedListener.class, String.class, String.class, int.class);
+ alternativeAddListenerMethod = true;
+ }
}
}
return addPrimaryClipChangedListener;
@@ -109,7 +135,7 @@ public class ClipboardManager {
public boolean addPrimaryClipChangedListener(IOnPrimaryClipChangedListener listener) {
try {
Method method = getAddPrimaryClipChangedListener();
- addPrimaryClipChangedListener(method, manager, listener);
+ addPrimaryClipChangedListener(method, alternativeAddListenerMethod, manager, listener);
return true;
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {
Ln.e("Could not invoke method", e); EDIT: new binary:
|
A new "attributionTag" parameter has been added to the methods getPrimaryClip(), setPrimaryClip() and addPrimaryClipChangedListener() of IClipboard.aidl. Refs <https://android.googlesource.com/platform/frameworks/base.git/+/0e3e509b3bf4d561c26d87213387a290dfd688e3%5E%21/> Fixes #3497 <#3497>
It's working fine here on Pixel 7. Thanks! |
Confirmed to be working for Pixel 6 Pro as well. Thanks! |
Merged into |
Confirmed on Pixel 4a on Mac 👍 Thanks for the update! |
Fixed in v1.25. |
I'm seeing this error with the default packages on Linux Mint 21.1 Vera. Should I pester them to update the package? Where should I do that? Many thanks, |
Uninstall the package and install the latest version manually: https://github.com/Genymobile/scrcpy/blob/master/doc/linux.md#latest-version |
Great, working. I'm just wondering when the deb / flatpak will be updated :-/ |
Device: Pixel 6 Pro
Android OS: 13 QPR Beta 1
Windows 10
Scrcpy 1.24
Terminal output when I press CTRL-V in scrcpy window:
EDIT by rom1v: Fixed in scrcpy v1.25.
The text was updated successfully, but these errors were encountered: