Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb760be58b | ||
|
|
bd9f656933 | ||
|
|
c243fd4c3f |
@@ -201,7 +201,7 @@ enable_tunnel_forward_any_port(struct server *server,
|
|||||||
|
|
||||||
if (port < port_range.last) {
|
if (port < port_range.last) {
|
||||||
LOGW("Could not forward port %" PRIu16", retrying on %" PRIu16,
|
LOGW("Could not forward port %" PRIu16", retrying on %" PRIu16,
|
||||||
port, port + 1);
|
port, (uint16_t) (port + 1));
|
||||||
port++;
|
port++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
// for portability
|
// for portability (kill, readlink, strdup, strtok_r)
|
||||||
#define _POSIX_SOURCE // for kill()
|
#define _POSIX_C_SOURCE 200809L
|
||||||
#define _BSD_SOURCE // for readlink()
|
#define _BSD_SOURCE
|
||||||
|
|
||||||
// modern glibc will complain without this
|
// modern glibc will complain without this
|
||||||
#define _DEFAULT_SOURCE
|
#define _DEFAULT_SOURCE
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ public class ContentProvider implements Closeable {
|
|||||||
private final IBinder token;
|
private final IBinder token;
|
||||||
|
|
||||||
private Method callMethod;
|
private Method callMethod;
|
||||||
private boolean callMethodLegacy;
|
private int callMethodVersion;
|
||||||
|
|
||||||
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,12 +46,20 @@ 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().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
|
callMethod = provider.getClass()
|
||||||
|
.getMethod("call", String.class, String.class, String.class, String.class, String.class, Bundle.class);
|
||||||
|
callMethodVersion = 0;
|
||||||
} catch (NoSuchMethodException e) {
|
} catch (NoSuchMethodException e) {
|
||||||
// old version
|
// old versions
|
||||||
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
|
try {
|
||||||
callMethodLegacy = true;
|
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, String.class, Bundle.class);
|
||||||
|
callMethodVersion = 1;
|
||||||
|
} catch (NoSuchMethodException e2) {
|
||||||
|
callMethod = provider.getClass().getMethod("call", String.class, String.class, String.class, Bundle.class);
|
||||||
|
callMethodVersion = 2;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return callMethod;
|
return callMethod;
|
||||||
@@ -61,10 +69,16 @@ public class ContentProvider implements Closeable {
|
|||||||
try {
|
try {
|
||||||
Method method = getCallMethod();
|
Method method = getCallMethod();
|
||||||
Object[] args;
|
Object[] args;
|
||||||
if (!callMethodLegacy) {
|
switch (callMethodVersion) {
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, "settings", callMethod, arg, extras};
|
case 0:
|
||||||
} else {
|
args = new Object[]{ServiceManager.PACKAGE_NAME, null, "settings", callMethod, arg, extras};
|
||||||
args = new Object[]{ServiceManager.PACKAGE_NAME, callMethod, arg, extras};
|
break;
|
||||||
|
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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user