From ae993ddf3bb0531124034565003a39a44f8f910b Mon Sep 17 00:00:00 2001 From: Xtr126 Date: Sun, 28 Jan 2024 08:48:46 +0530 Subject: [PATCH] Add --tcpip flag to server --- .../java/xtr/keymapper/server/RemoteService.java | 12 +++++++++--- .../server/RemoteServiceSocketClient.java | 15 ++++++++++----- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/xtr/keymapper/server/RemoteService.java b/app/src/main/java/xtr/keymapper/server/RemoteService.java index e142392a..37daa2f5 100644 --- a/app/src/main/java/xtr/keymapper/server/RemoteService.java +++ b/app/src/main/java/xtr/keymapper/server/RemoteService.java @@ -38,14 +38,19 @@ public RemoteService(String[] args) { super(); Log.i("XtMapper", "starting server..."); try { - ServiceManager.addService("xtmapper", this); System.out.println("Waiting for overlay..."); for (String arg: args) { if (arg.equals("--wayland-client")) { isWaylandClient = true; System.out.println("using wayland client"); } + if (arg.equals("--tcpip")) { + start_getevent(); + System.out.println("using tcpip"); + new RemoteServiceSocketServer(this); + } } + ServiceManager.addService("xtmapper", this); start_getevent(); } catch (Exception e) { e.printStackTrace(System.out); @@ -177,7 +182,8 @@ public static void loadLibraries() { } public static IRemoteService getInstance(){ - return IRemoteService.Stub.asInterface(ServiceManager.getService("xtmapper")); +// return IRemoteService.Stub.asInterface(ServiceManager.getService("xtmapper")); + return new RemoteServiceSocketClient(); } -} \ No newline at end of file +} diff --git a/app/src/main/java/xtr/keymapper/server/RemoteServiceSocketClient.java b/app/src/main/java/xtr/keymapper/server/RemoteServiceSocketClient.java index 3a027927..c4c8b25d 100644 --- a/app/src/main/java/xtr/keymapper/server/RemoteServiceSocketClient.java +++ b/app/src/main/java/xtr/keymapper/server/RemoteServiceSocketClient.java @@ -14,7 +14,16 @@ public class RemoteServiceSocketClient implements IRemoteService { - private LocalSocket socket; + private final LocalSocket socket; + + public RemoteServiceSocketClient() { + socket = new LocalSocket(); + try { + socket.connect(new LocalSocketAddress("xtmapper-a3e11694")); + } catch (IOException e) { + throw new RuntimeException(e); + } + } static private void writeTypedObject( android.os.Parcel parcel, T value, int parcelableFlags) { @@ -47,10 +56,6 @@ private boolean transactRemote(int code, Parcel data, Parcel reply, int flags) { } return true; } - public void init() throws IOException { - socket = new LocalSocket(); - socket.connect(new LocalSocketAddress("xtmapper-a3e11694")); - } @Override public boolean isRoot() {