mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-12-17 13:34:20 +01: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:
@@ -5,7 +5,6 @@ import com.genymobile.scrcpy.wrappers.ServiceManager;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.AttributionSource;
|
||||
import android.content.ClipboardManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.Context;
|
||||
import android.content.ContextWrapper;
|
||||
@@ -91,6 +90,11 @@ public final class FakeContext extends ContextWrapper {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Context createPackageContext(String packageName, int flags) {
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ContentResolver getContentResolver() {
|
||||
return contentResolver;
|
||||
@@ -104,9 +108,11 @@ public final class FakeContext extends ContextWrapper {
|
||||
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 {
|
||||
Field field = ClipboardManager.class.getDeclaredField("mContext");
|
||||
Field field = service.getClass().getDeclaredField("mContext");
|
||||
field.setAccessible(true);
|
||||
field.set(service, this);
|
||||
} catch (ReflectiveOperationException e) {
|
||||
|
||||
Reference in New Issue
Block a user