adb: fix -Tt options to match ssh.

ssh has slightly more sophisticated -Tt options that we want to match.
This CL changes -Tt behavior to match ssh so that we allocate a remote
PTY in these cases:
     -T: never.
       : if stdin is a terminal and user wants an interactive shell.
     -t: if stdin is a terminal (otherwise print a warning message).
  -t -t: always.

Now this will work as expected:
  $ adb shell < my_script.sh

Also corrects a small unrelated bug with escape sequences so that only
a single tilde is accepted for the disconnect sequence.

Bug: http://b/24565284
Change-Id: Idab57ac98d81233b45c2613fe64ceb4398add961
1 file changed