WifiManager: Defer Async Channel init
Now that WifiManager instances are separate and do not depend on a single static AsyncChannel for the entire process, all contexts within a process will create an async channel on init. Since creating this channel requires special permissions that some applications do not have, it is problematic for them all to request it in the process of getting a WifiManager instance. This CL defers AsyncChannel initialization until it is actually going to be used. This allows callers to create WifiManager instances without necessarily creating an AsyncChannel. Depending on what parts of the API will be used, some callers will never need one. Also, this means that these apps will not run afoul of permissions exceptions that do not apply to them unless they actually request functionality that requires the AsyncChannel. While here, this CL no longer catches SecurityException while requesting a messenger from WifiService. That hack appeared to be an artifact of the static instance of sAsyncChannel -- it was not clear to WifiManager which context had permissions to successfully create the messenger, so it was necessary to silently fail the attempt especially since that attempt was made in the constructor. With the restructuring to keep mAsyncChannel per-instance and now only created at the time specific API calls require it, a SecurityException is completely relevant to the caller and should not be discarded. Bug: 27694933 Test: Boot full image, repro b/27694933 with com.google.android.music Change-Id: I680bf2443bc5b057e629544a687f985261201ded
Loading
Please register or sign in to comment