Skip to content

Commit

Permalink
fix: exit process to avoid ANR on clicking stop button
Browse files Browse the repository at this point in the history
  • Loading branch information
Xtr126 committed Sep 21, 2024
1 parent dd902e1 commit 7ef9e7a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 4 additions & 2 deletions app/src/main/java/xtr/keymapper/server/RemoteService.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ public class RemoteService extends IRemoteService.Stub {
private final WindowManager windowManager;
final Context context;
public static final String TAG = "xtmapper-server";
boolean startedFromShell = false;

/* For Shizuku UserService */
public RemoteService(Context context) {
loadLibraries();
this.context = context;
Expand Down Expand Up @@ -226,7 +226,9 @@ public void startServer(KeymapProfile profile, KeymapConfig keymapConfig, IRemot

@Override
public void stopServer() {
if (inputService != null && !isWaylandClient) {
if (!startedFromShell) {
System.exit(0);
} else if (inputService != null && !isWaylandClient) {
inputService.stopEvents = true;
inputService.hideCursor();
inputService.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public static void main(String[] args) {
RemoteService.loadLibraries();
Looper.prepareMainLooper();
RemoteService mService = new RemoteService(getContext());
mService.startedFromShell = true;

boolean launchApp = true;
for (String arg: args) {
Expand Down

0 comments on commit 7ef9e7a

Please sign in to comment.