Use API for binding service with custom user and executor.
There is actually already a public API overload for Context.bindService() which allows binding the service with the user of Context.getUser() and a custom Executor. We can construct an Executor from our Handler, but this executor is required to remain the same instance for different calls to bindService() for the same ServiceConnection by the API, so we should keep the Executor instance, as well as the Handler instance, instead of calling getJobHandler() every time. In fact getJobHandler() is already required to return the same instance, or bindServiceAsUser() would have thrown the same exception for different Handlers. Also removed a check in ContextImpl.bindService() to allow mainline modules to use the bindService() API with Context multi-user. Bug: 158736025 Test: presubmit Change-Id: I95717a4a74267dff4fbe1898a82cdfa7f195cc06
Loading
Please register or sign in to comment