private boolean validateNetworkConnection(){
  StringBuffer str=new StringBuffer("States ");
  str.append(printStates());
  if (mStateDepository.get(0) != State.DISCONNECTED) {
    str.append(String.format(" Initial state should be DISCONNECTED, but it is %s.",mStateDepository.get(0)));
    mReason=str.toString();
    return false;
  }
  State lastState=mStateDepository.get(mStateDepository.size() - 1);
  if (lastState != mTransitionTarget) {
    str.append(String.format(" Last state should be %s, but it is %s",mTransitionTarget,lastState));
    mReason=str.toString();
    return false;
  }
  for (int i=1; i < mStateDepository.size(); i++) {
    State preState=mStateDepository.get(i - 1);
    State curState=mStateDepository.get(i);
    if ((preState == State.DISCONNECTED) && ((curState == State.CONNECTING) || (curState == State.CONNECTED) || (curState == State.DISCONNECTED))) {
      continue;
    }
 else     if ((preState == State.CONNECTING) && (curState == State.CONNECTED)) {
      continue;
    }
 else     if ((preState == State.CONNECTED) && (curState == State.CONNECTED)) {
      continue;
    }
 else {
      str.append(String.format(" Transition state from %s to %s is not valid.",preState.toString(),curState.toString()));
      mReason=str.toString();
      return false;
    }
  }
  mReason=str.toString();
  return true;
}

private boolean validateNetworkConnection ( ) { StringBuffer str = new StringBuffer ( "States " ) ; str . append ( printStates ( ) ) ; if ( mStateDepository . get ( 0 ) != State . DISCONNECTED ) { str . append ( String . format ( " Initial state should be DISCONNECTED, but it is %s." , mStateDepository . get ( 0 ) ) ) ; mReason = str . toString ( ) ; return false ; } State lastState = mStateDepository . get ( mStateDepository . size ( ) - 1 ) ; if ( lastState != mTransitionTarget ) { str . append ( String . format ( " Last state should be %s, but it is %s" , mTransitionTarget , lastState ) ) ; mReason = str . toString ( ) ; return false ; } for ( int i = 1 ; i < mStateDepository . size ( ) ; i ++ ) { State preState = mStateDepository . get ( i - 1 ) ; State curState = mStateDepository . get ( i ) ; if ( ( preState == State . DISCONNECTED ) && ( ( curState == State . CONNECTING ) || ( curState == State . CONNECTED ) || ( curState == State . DISCONNECTED ) ) ) { continue ; } else if ( ( preState == State . CONNECTING ) && ( curState == State . CONNECTED ) ) { continue ; } else if ( ( preState == State . CONNECTED ) && ( curState == State . CONNECTED ) ) { continue ; } else { str . append ( String . format ( " Transition state from %s to %s is not valid." , preState . toString ( ) , curState . toString ( ) ) ) ; mReason = str . toString ( ) ; return false ; } } mReason = str . toString ( ) ; return true ; }
verify the network state to connection
