Skip to content

Commit ee7de95

Browse files
committed
#1376 fix: use new key event relay service AIDL definition for unregistering a specific callback
1 parent 9f17b82 commit ee7de95

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

app/src/main/aidl/io/github/sds100/keymapper/api/IKeyEventRelayService.aidl

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,12 @@ interface IKeyEventRelayService {
1818
void registerCallback(IKeyEventRelayServiceCallback client);
1919

2020
/**
21-
* Unregister a callback to receive key events from this relay service. The service
22-
* checks the process uid of the caller to this method and only permits certain applications
23-
* from connecting.
21+
* Unregister all the callbacks associated with the calling package from this relay service.
22+
*/
23+
void unregisterAllCallbacks();
24+
25+
/**
26+
* Unregister a callback to receive key events from this relay service.
2427
*/
25-
void unregisterCallback();
28+
void unregisterCallback(IKeyEventRelayServiceCallback client);
2629
}

app/src/main/java/io/github/sds100/keymapper/inputmethod/latin/KeyEventRelayServiceWrapper.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,9 @@ class KeyEventRelayServiceWrapperImpl(
128128
}
129129
} catch (e: SecurityException) {
130130
Log.e(LatinIME.TAG, e.toString())
131+
132+
// Docs say to unbind if there is a security exception.
133+
ctx.unbindService(serviceConnection)
131134
}
132135
}
133136

@@ -138,7 +141,7 @@ class KeyEventRelayServiceWrapperImpl(
138141
// because the connection is already broken at that point and it
139142
// will fail.
140143
try {
141-
keyEventRelayService?.unregisterCallback()
144+
keyEventRelayService?.unregisterCallback(callback)
142145
ctx.unbindService(serviceConnection)
143146
} catch (e: RemoteException) {
144147
// do nothing

0 commit comments

Comments
 (0)