
The onConnected callback of ServiceConnection is always executed on the main looper of the context that is used to create the service binding. Thus the old code resulted in a deadlock and then in a timeout of the Thread.wait() method. The check for permissions is now called inside install and uninstall callbacks, where it works asynchronously.