Compare commits

..
1 Commits
Author SHA1 Message Date
Romain Vimont dd73a71a15 Fix feature test macro
The expected feature test macro is _POSIX_C_SOURCE, not _POSIX_SOURCE.

Fixes #1726 <https://github.com/Genymobile/scrcpy/issues/1726>
2020-08-31 14:01:30 +02:00
@@ -35,7 +35,7 @@ public class ContentProvider implements Closeable {
private final IBinder token; private final IBinder token;
private Method callMethod; private Method callMethod;
private int callMethodVersion; private boolean callMethodLegacy;
ContentProvider(ActivityManager manager, Object provider, String name, IBinder token) { ContentProvider(ActivityManager manager, Object provider, String name, IBinder token) {
this.manager = manager; this.manager = manager;
@@ -46,20 +46,12 @@ public class ContentProvider implements Closeable {
private Method getCallMethod() throws NoSuchMethodException { private Method getCallMethod() throws NoSuchMethodException {
if (callMethod == null) { if (callMethod == null) {
try { try {
callMethod = provider.getClass() callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
.getMethod("call", String.class, String.class, String.class, String.class, String.class, Bundle.class);
callMethodVersion = 0;
} catch (NoSuchMethodException e) { } catch (NoSuchMethodException e) {
// old versions // old version
try { callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class); callMethodLegacy = true;
callMethodVersion = 1;
} catch (NoSuchMethodException e2) {
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
callMethodVersion = 2;
}
} }
} }
return callMethod; return callMethod;
@@ -69,16 +61,10 @@ public class ContentProvider implements Closeable {
try { try {
Method method = getCallMethod(); Method method = getCallMethod();
Object[] args; Object[] args;
switch (callMethodVersion) { if (!callMethodLegacy) {
case 0: args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
args = new Object[]{ServiceManager.PACKAGE_NAME, null, "settings", callMethod, arg, extras}; } else {
break; args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
case 1:
args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
break;
default:
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
break;
} }
return (Bundle) method.invoke(provider, args); return (Bundle) method.invoke(provider, args);
} catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) { } catch (InvocationTargetException | IllegalAccessException | NoSuchMethodException e) {