wait for response for x time, send a message by x time, or when response receive

My android app is going to send a stream of bytes, 2 byte at a time.

The arduino is to receive them 2 byte at a time, and reply "w" when it receives them, telling android to send then next 2.

The problem i got it that sometimes, the stream pauses due to android not receiving a "w", as "w" might be sent during the times the Android might be processing the next byte, and flags in there were reset, ignoring the "w" received.

So I want to let the arduino, whenever the serial buffer is 0, to
1)send a "w"
2)send a "w" again, after 1millisecond, if no response is received.

Is this the right way to do it?

unsigned long Timer;
unsigned long inteval = 1;


while( s0 != '|' || s1 != '|' ){//terminates if '|' is received

			if(s0 == '|' || s1 == '|')break;
			
			else if(HWSERIAL.available() == 0){
                                HWSERIAL.print("w");//tell Android to send next byte

				Timer = millis();
				if(HWSERIAL.available() == 0 && millis() - Timer > 1){
					HWSERIAL.print("w");//tell Android to send next byte
				}
			}
			else if(HWSERIAL.available() >= 2) {
				
				s0=HWSERIAL.read();
				s1=HWSERIAL.read();
                                <some IO operations>