Home | History | Annotate | Download | only in bandwidthtest

Lines Matching refs:State

19 import android.net.NetworkInfo.State;
26 * Data structure to keep track of the network state transitions.
30 * Desired direction of state transition.
36 private List<State> mStateDepository;
37 private State mTransitionTarget;
39 private String mReason = null; // record mReason of state transition failure
42 mStateDepository = new ArrayList<State>();
44 mTransitionTarget = State.UNKNOWN;
47 public NetworkState(State currentState) {
48 mStateDepository = new ArrayList<State>();
51 mTransitionTarget = State.UNKNOWN;
55 * Reinitialize the network state
60 mTransitionTarget = State.UNKNOWN;
65 * @param initState initial {@link State}
67 * @param targetState desired {@link State}
69 public void setStateTransitionCriteria(State initState, StateTransitionDirection transitionDir,
70 State targetState) {
81 * Record the current state of the network
82 * @param currentState the current {@link State}
84 public void recordState(State currentState) {
89 * Verify the state transition
93 Log.v(LOG_TAG, String.format("Print state depository: %s", printStates()));
116 Log.v(LOG_TAG, "no state is recorded");
117 mReason = "no state is recorded.";
136 * Verify the network state to disconnection
137 * @return false if any of the state transitions were not valid
143 if (mStateDepository.get(0) != State.CONNECTED) {
144 str.append(String.format(" Initial state should be CONNECTED, but it is %s.",
149 State lastState = mStateDepository.get(mStateDepository.size() - 1);
151 str.append(String.format(" Last state should be DISCONNECTED, but it is %s",
157 State preState = mStateDepository.get(i-1);
158 State curState = mStateDepository.get(i);
159 if ((preState == State.CONNECTED) && ((curState == State.DISCONNECTING) ||
160 (curState == State.DISCONNECTED))) {
162 } else if ((preState == State.DISCONNECTING) && (curState == State.DISCONNECTED)) {
164 } else if ((preState == State.DISCONNECTED) && (curState == State.DISCONNECTED)) {
167 str.append(String.format(" Transition state from %s to %s is not valid",
178 * Verify the network state to connection
179 * @return false if any of the state transitions were not valid
184 if (mStateDepository.get(0) != State.DISCONNECTED) {
185 str.append(String.format(" Initial state should be DISCONNECTED, but it is %s.",
190 State lastState = mStateDepository.get(mStateDepository.size() - 1);
192 str.append(String.format(" Last state should be %s, but it is %s", mTransitionTarget,
198 State preState = mStateDepository.get(i-1);
199 State curState = mStateDepository.get(i);
200 if ((preState == State.DISCONNECTED) && ((curState == State.CONNECTING) ||
201 (curState == State.CONNECTED) || (curState == State.DISCONNECTED))) {
203 } else if ((preState == State.CONNECTING) && (curState == State.CONNECTED)) {
205 } else if ((preState == State.CONNECTED) && (curState == State.CONNECTED)) {
208 str.append(String.format(" Transition state from %s to %s is not valid.",
219 * Fetch the different network state transitions
220 * @return {@link List} of {@link State}
222 public List<State> getTransitionStates() {
227 * Fetch the reason for network state transition failure
235 * Print the network state
236 * @return {@link String} representation of the network state