Fix propagating underlying caps when a network disconnects.
aosp/1513052, which generalized support for underlying networks, broke default network switching when the network underlying a VPN disconnects. This is because it calls propagateUnderlyingNetworkCapabilities in the middle of the bookkeeping operations needed when a network is disconnected (specifically, after all satisified requests are removed from the disconnecting network, but before mDefaultNetworkNai is updated). This is completely incorrect because propagateUnderlyingNetworkCapabilities can trigger a network rematch, and running a rematch when the request data structures are inconsistent is obviously wrong. See the test changes in this CL for an example of the damage. Fix this by moving propagateUnderlyingNetworkCapabilities to before the bookeeping operations begin. It must be before mDefaultNetworkNai is updated, because otherwise it will not know that the default network is disconnecting, and it will not be able to propagate capabilities to VPNs that set underlying networks to null (i.e., to the default network). It must be after the nai is removed from mNetworkForNetId because otherwise it will think that the underlying network is still connected. Bug: 173331190 Test: accompanying unit test shows lots of bugs removed Change-Id: Ibf376a6fa4b34d1c96f8506fa8abbb7595a8c272
Loading
Please register or sign in to comment