Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_frameworks_base-old
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Farzin Kazemzadeh
platform_frameworks_base-old
Commits
513f7d83
Commit
513f7d83
authored
2 years ago
by
Roman Kiryanov
Committed by
Gerrit Code Review
2 years ago
Browse files
Options
Downloads
Plain Diff
Merge "Cleanup in EmulatorClipboardMonitor (4)"
parents
306e3bb8
cfe2796f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java
+31
-22
31 additions, 22 deletions
...om/android/server/clipboard/EmulatorClipboardMonitor.java
with
31 additions
and
22 deletions
services/core/java/com/android/server/clipboard/EmulatorClipboardMonitor.java
+
31
−
22
View file @
513f7d83
...
...
@@ -169,34 +169,43 @@ class EmulatorClipboardMonitor implements Consumer<ClipData> {
@Override
public
void
accept
(
final
@Nullable
ClipData
clip
)
{
if
(
clip
==
null
)
{
setHostClipboardImpl
(
""
);
}
else
if
(
clip
.
getItemCount
()
>
0
)
{
final
CharSequence
text
=
clip
.
getItemAt
(
0
).
getText
();
if
(
text
!=
null
)
{
setHostClipboardImpl
(
text
.
toString
());
}
final
FileDescriptor
fd
=
getPipeFD
();
if
(
fd
!=
null
)
{
setHostClipboard
(
fd
,
getClipString
(
clip
));
}
}
private
void
setHostClipboardImpl
(
final
String
value
)
{
final
FileDescriptor
pipeFD
=
getPipeFD
();
private
String
getClipString
(
final
@Nullable
ClipData
clip
)
{
if
(
clip
==
null
)
{
return
""
;
}
if
(
pipeFD
!=
null
)
{
Thread
t
=
new
Thread
(()
->
{
if
(
LOG_CLIBOARD_ACCESS
)
{
Slog
.
i
(
TAG
,
"Setting the host clipboard to '"
+
value
+
"'"
);
}
if
(
clip
.
getItemCount
()
==
0
)
{
return
""
;
}
try
{
sendMessage
(
pipeFD
,
value
.
getBytes
());
}
catch
(
ErrnoException
|
InterruptedIOException
e
)
{
Slog
.
e
(
TAG
,
"Failed to set host clipboard "
+
e
.
getMessage
());
}
catch
(
IllegalArgumentException
e
)
{
}
});
t
.
start
();
final
CharSequence
text
=
clip
.
getItemAt
(
0
).
getText
();
if
(
text
==
null
)
{
return
""
;
}
return
text
.
toString
();
}
private
static
void
setHostClipboard
(
final
FileDescriptor
fd
,
final
String
value
)
{
Thread
t
=
new
Thread
(()
->
{
if
(
LOG_CLIBOARD_ACCESS
)
{
Slog
.
i
(
TAG
,
"Setting the host clipboard to '"
+
value
+
"'"
);
}
try
{
sendMessage
(
fd
,
value
.
getBytes
());
}
catch
(
ErrnoException
|
InterruptedIOException
e
)
{
Slog
.
e
(
TAG
,
"Failed to set host clipboard "
+
e
.
getMessage
());
}
catch
(
IllegalArgumentException
e
)
{
}
});
t
.
start
();
}
private
static
void
readFully
(
final
FileDescriptor
fd
,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment