mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-10-02 22:28:40 +00:00
Workaround clipboard issue on Samsung devices
Fixes #6224 <https://github.com/Genymobile/scrcpy/issues/6224> Co-authored-by: Simon Chan <1330321+yume-chan@users.noreply.github.com>
This commit is contained in:
parent
afaca80b37
commit
4ee94cb845
1 changed files with 9 additions and 3 deletions
|
@ -5,7 +5,6 @@ import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
import android.annotation.TargetApi;
|
import android.annotation.TargetApi;
|
||||||
import android.content.AttributionSource;
|
import android.content.AttributionSource;
|
||||||
import android.content.ClipboardManager;
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.content.ContextWrapper;
|
import android.content.ContextWrapper;
|
||||||
|
@ -91,6 +90,11 @@ public final class FakeContext extends ContextWrapper {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Context createPackageContext(String packageName, int flags) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContentResolver getContentResolver() {
|
public ContentResolver getContentResolver() {
|
||||||
return contentResolver;
|
return contentResolver;
|
||||||
|
@ -104,9 +108,11 @@ public final class FakeContext extends ContextWrapper {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Context.CLIPBOARD_SERVICE.equals(name)) {
|
// "semclipboard" is a Samsung-internal service
|
||||||
|
// See <https://github.com/Genymobile/scrcpy/issues/6224>
|
||||||
|
if (Context.CLIPBOARD_SERVICE.equals(name) || "semclipboard".equals(name)) {
|
||||||
try {
|
try {
|
||||||
Field field = ClipboardManager.class.getDeclaredField("mContext");
|
Field field = service.getClass().getDeclaredField("mContext");
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
field.set(service, this);
|
field.set(service, this);
|
||||||
} catch (ReflectiveOperationException e) {
|
} catch (ReflectiveOperationException e) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue