mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-07-30 04:38:51 +00:00
Create ClipboardManager from the main thread
The ClipboardManager is instantiated by the first call to
ServiceManager.getClipboardManager().
Now that scrcpy uses android.content.ClipboardManager directly, it must
ensure that it is created on the main thread (or at least on a thread
with a Looper), to avoid the following error:
> Can't create handler inside thread that has not called
> Looper.prepare()
Refs 8a02e3c2f5
Fixes #6151 <https://github.com/Genymobile/scrcpy/issues/6151>
This commit is contained in:
parent
772f42134a
commit
cd3a5d50b6
1 changed files with 2 additions and 1 deletions
|
@ -114,9 +114,10 @@ public class Controller implements AsyncProcessor, VirtualDisplayListener {
|
|||
Ln.w("Input events are not supported for secondary displays before Android 10");
|
||||
}
|
||||
|
||||
// Make sure the clipboard manager is always created from the main thread (even if clipboardAutosync is disabled)
|
||||
ClipboardManager clipboardManager = ServiceManager.getClipboardManager();
|
||||
if (clipboardAutosync) {
|
||||
// If control and autosync are enabled, synchronize Android clipboard to the computer automatically
|
||||
ClipboardManager clipboardManager = ServiceManager.getClipboardManager();
|
||||
if (clipboardManager != null) {
|
||||
clipboardManager.addPrimaryClipChangedListener(() -> {
|
||||
if (isSettingClipboard.get()) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue