Skip to content
Commit a95881f6 authored by Hai Zhang's avatar Hai Zhang
Browse files

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
parent bb45c563
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment