OSDN Git Service

Fix race conditions between Tethering and TetherInterfaceStateMachine
authorChristopher Wiley <wiley@google.com>
Tue, 31 May 2016 17:44:35 +0000 (10:44 -0700)
committerChristopher Wiley <wiley@google.com>
Tue, 7 Jun 2016 20:10:03 +0000 (13:10 -0700)
commitde4819dc82b734036b22416228327d2712e01884
treeb43935cc25dbdf7ce56e79130fa6d7dbdc02776b
parentffd1fc22d416c60e39a295cec780338d46b8646b
Fix race conditions between Tethering and TetherInterfaceStateMachine

Previously, Tethering would answer requests for current tethering state
by calling methods on instances of TetherInterfaceStateMachine to build
up that state. This is incorrect, since state queries can come in on an
arbitrary thread, independent of updates to the state machines
instances.

Fix this by:
  - Altering TetherInterfaceStateMachine to push consistent state
    snapshots to Tethering via notifyInterfaceStateChange()
  - Storing the last state snapshot in Tethering.mTetherStates
  - Removing public methods to query TetherInterfaceStateMachine state.
  - Consistently synchronizing access to Tethering.mTetherStates

Bug: 29009601
Test: WiFi Tethering continues to work, unittests continue to pass

Change-Id: Ied334f5e8739bc3aff1b08a1079095b9cc2a7958
services/core/java/com/android/server/connectivity/Tethering.java
services/core/java/com/android/server/connectivity/tethering/IControlsTethering.java
services/core/java/com/android/server/connectivity/tethering/TetherInterfaceStateMachine.java
services/tests/servicestests/src/com/android/server/connectivity/tethering/TetherInterfaceStateMachineTest.java