private void transitionTo(int newState) {
        if (state == newState) {
            return;
        }

        switch (newState) {
            case STATE_HANDSHAKE_STARTED:
                handshakeStartedMillis = Platform.getMillisSinceBoot();
                break;

            case STATE_READY:
                if (handshakeStartedMillis != 0) {
                    StatsLog statsLog = Platform.getStatsLog();
                    if (statsLog != null) {
                        statsLog.countTlsHandshake(true, activeSession.getProtocol(),
                                activeSession.getCipherSuite(),
                                Platform.getMillisSinceBoot() - handshakeStartedMillis);
                    }
                    handshakeStartedMillis = 0;
                }
                break;

            case STATE_CLOSED: {
                if (handshakeStartedMillis != 0) {
                    // Handshake was in progress so must have failed.
                    StatsLog statsLog = Platform.getStatsLog();
                    if (statsLog != null) {
                        statsLog.countTlsHandshake(false, "TLS_PROTO_FAILED", "TLS_CIPHER_FAILED",
                                Platform.getMillisSinceBoot() - handshakeStartedMillis);
                    }
                    handshakeStartedMillis = 0;
                }
                if (!ssl.isClosed() && state >= STATE_HANDSHAKE_STARTED && state < STATE_CLOSED) {
                    closedSession = new SessionSnapshot(activeSession);
                }
                break;
            }
            default: {
                break;
            }
        }

        // Update the state
        this.state = newState;
    }
Set the handshake timeout on this socket.  This timeout is specified in
milliseconds and will be used only during the handshake process.
common/src/main/java/org/conscrypt/ConscryptFileDescriptorSocket.java