summaryrefslogtreecommitdiff
path: root/tools/aapt2/java/JavaClassGenerator_test.cpp
diff options
context:
space:
mode:
authorLorenzo Colitti <lorenzo@google.com>2020-04-06 11:24:19 +0000
committerLorenzo Colitti <lorenzo@google.com>2020-04-06 15:46:38 +0000
commit879c0eb013d5f6c970d5bc8edc425967e10c04cf (patch)
tree08be703b58597878e222768920c77722986385d5 /tools/aapt2/java/JavaClassGenerator_test.cpp
parenta775f45d853c523ddeb0f3bcff3d7593ecbe3c4c (diff)
Refactor the Nat464Xlat function for simplicity.
This makes the code easier to understand by making state transitions more explicit. It also makes it easier to address a TODO to turn the class into a StateMachine. This should be an exact no-op refactoring. The current cases covered by the code (all mutually exclusive) are: 1. requiresClat && !isPrefixDiscoveryStarted Action: startPrefixDiscovery() Equivalent to IDLE && requiresClat, because isPrefixDiscoveryStarted returns true for every state except IDLE. 2. requiresClat && isPrefixDiscoveryStarted && shouldStartClat Action: start() Equivalent to DISCOVERING && shouldStartClat, because isPrefixDiscoveryStarted is true in DISCOVERING, STARTING, and RUNNING, but start() does nothing if mState is STARTING or RUNNING. 3. requiresClat && isPrefixDiscoveryStarted && !shouldStartClat Action: stop() Equivalent to (STARTING or RUNNING) && !shouldStartClat, because isPrefixDiscoveryStarted is true in DISCOVERING, STARTING, and RUNNING, but stop() does nothing if mState is not STARTING or RUNNING. 4. !requiresClat && isStarted Action: stop() Equivalent to (STARTING or RUNNING) && !requiresClat, because isStarted() is only true in STARTING and RUNNING. 5. !requiresClat && !isStarted && isPrefixDiscoveryStarted Action: leaveStartedState() Equivalent to DISCOVERING && !requiresClat, because the only state with isPrefixDiscoveryStarted and !isStarted is DISCOVERING. Also, simplify case #5. In this case, calling leaveStartedState is superfluous, because in the DISCOVERING state: - There is no need to call unregisterObserver, since the observer is only registered when entering STARTING and is unregistered when going back to DISCOVERING or IDLE. - mIface and mBaseIface don't need to be set to null because they are only set to non-null when entering STARTING and nulled out when going back to DISCOVERING or IDLE. Bug: 126113090 Bug: 150648313 Test: covered by existing ConnectivityServiceTest and Nat464XlatTest Merged-In: Ice536bcb269cc8b040c6e7a72c15d0bc8b5bd235 Change-Id: Ice536bcb269cc8b040c6e7a72c15d0bc8b5bd235
Diffstat (limited to 'tools/aapt2/java/JavaClassGenerator_test.cpp')
0 files changed, 0 insertions, 0 deletions