Compare commits
2 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
ad8b824a28 | ||
|
d1a0f9b054 |
@ -38,38 +38,53 @@ public final class ClipboardManager {
|
|||||||
if (getPrimaryClipMethod == null) {
|
if (getPrimaryClipMethod == null) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class);
|
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class);
|
||||||
} else {
|
return getPrimaryClipMethod;
|
||||||
try {
|
|
||||||
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
|
|
||||||
getMethodVersion = 0;
|
|
||||||
} catch (NoSuchMethodException e1) {
|
|
||||||
try {
|
|
||||||
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class);
|
|
||||||
getMethodVersion = 1;
|
|
||||||
} catch (NoSuchMethodException e2) {
|
|
||||||
try {
|
|
||||||
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class, int.class);
|
|
||||||
getMethodVersion = 2;
|
|
||||||
} catch (NoSuchMethodException e3) {
|
|
||||||
try {
|
|
||||||
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class, String.class);
|
|
||||||
getMethodVersion = 3;
|
|
||||||
} catch (NoSuchMethodException e4) {
|
|
||||||
try {
|
|
||||||
getPrimaryClipMethod = manager.getClass()
|
|
||||||
.getMethod("getPrimaryClip", String.class, String.class, int.class, int.class, boolean.class);
|
|
||||||
getMethodVersion = 4;
|
|
||||||
} catch (NoSuchMethodException e5) {
|
|
||||||
getPrimaryClipMethod = manager.getClass()
|
|
||||||
.getMethod("getPrimaryClip", String.class, String.class, String.class, String.class, int.class, int.class,
|
|
||||||
boolean.class);
|
|
||||||
getMethodVersion = 5;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class);
|
||||||
|
getMethodVersion = 0;
|
||||||
|
return getPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class);
|
||||||
|
getMethodVersion = 1;
|
||||||
|
return getPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class, int.class);
|
||||||
|
getMethodVersion = 2;
|
||||||
|
return getPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, int.class, String.class);
|
||||||
|
getMethodVersion = 3;
|
||||||
|
return getPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getPrimaryClipMethod = manager.getClass()
|
||||||
|
.getMethod("getPrimaryClip", String.class, String.class, int.class, int.class, boolean.class);
|
||||||
|
getMethodVersion = 4;
|
||||||
|
return getPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
getPrimaryClipMethod = manager.getClass()
|
||||||
|
.getMethod("getPrimaryClip", String.class, String.class, String.class, String.class, int.class, int.class, boolean.class);
|
||||||
|
getMethodVersion = 5;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
getPrimaryClipMethod = manager.getClass().getMethod("getPrimaryClip", String.class, String.class, int.class, int.class, String.class);
|
||||||
|
getMethodVersion = 6;
|
||||||
}
|
}
|
||||||
return getPrimaryClipMethod;
|
return getPrimaryClipMethod;
|
||||||
}
|
}
|
||||||
@ -78,27 +93,33 @@ public final class ClipboardManager {
|
|||||||
if (setPrimaryClipMethod == null) {
|
if (setPrimaryClipMethod == null) {
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q) {
|
||||||
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class);
|
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class);
|
||||||
} else {
|
return setPrimaryClipMethod;
|
||||||
try {
|
|
||||||
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
|
|
||||||
setMethodVersion = 0;
|
|
||||||
} catch (NoSuchMethodException e1) {
|
|
||||||
try {
|
|
||||||
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class);
|
|
||||||
setMethodVersion = 1;
|
|
||||||
} catch (NoSuchMethodException e2) {
|
|
||||||
try {
|
|
||||||
setPrimaryClipMethod = manager.getClass()
|
|
||||||
.getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class, int.class);
|
|
||||||
setMethodVersion = 2;
|
|
||||||
} catch (NoSuchMethodException e3) {
|
|
||||||
setPrimaryClipMethod = manager.getClass()
|
|
||||||
.getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class, int.class, boolean.class);
|
|
||||||
setMethodVersion = 3;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, int.class);
|
||||||
|
setMethodVersion = 0;
|
||||||
|
return setPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
setPrimaryClipMethod = manager.getClass().getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class);
|
||||||
|
setMethodVersion = 1;
|
||||||
|
return setPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall through
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
setPrimaryClipMethod = manager.getClass()
|
||||||
|
.getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class, int.class);
|
||||||
|
setMethodVersion = 2;
|
||||||
|
return setPrimaryClipMethod;
|
||||||
|
} catch (NoSuchMethodException e) {
|
||||||
|
// fall though
|
||||||
|
}
|
||||||
|
setPrimaryClipMethod = manager.getClass()
|
||||||
|
.getMethod("setPrimaryClip", ClipData.class, String.class, String.class, int.class, int.class, boolean.class);
|
||||||
|
setMethodVersion = 3;
|
||||||
}
|
}
|
||||||
return setPrimaryClipMethod;
|
return setPrimaryClipMethod;
|
||||||
}
|
}
|
||||||
@ -120,8 +141,10 @@ public final class ClipboardManager {
|
|||||||
case 4:
|
case 4:
|
||||||
// The last boolean parameter is "userOperate"
|
// The last boolean parameter is "userOperate"
|
||||||
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID, 0, true);
|
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID, 0, true);
|
||||||
default:
|
case 5:
|
||||||
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, null, null, FakeContext.ROOT_UID, 0, true);
|
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, null, null, FakeContext.ROOT_UID, 0, true);
|
||||||
|
default:
|
||||||
|
return (ClipData) method.invoke(manager, FakeContext.PACKAGE_NAME, null, FakeContext.ROOT_UID, 0, null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user