Remove long-dead readtty.
Change-Id: I15ae14542214a3802d43892da0d03cfb33e63c96
This commit is contained in:
parent
1fc78d3d0b
commit
b120134bd1
3 changed files with 0 additions and 506 deletions
|
@ -232,7 +232,6 @@ static const struct fs_path_config android_files[] = {
|
|||
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.goldfish.sh" },
|
||||
{ 00440, AID_ROOT, AID_SHELL, 0, "system/etc/init.trout.rc" },
|
||||
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.ril" },
|
||||
{ 00550, AID_ROOT, AID_SHELL, 0, "system/etc/init.testmenu" },
|
||||
{ 00550, AID_DHCP, AID_SHELL, 0, "system/etc/dhcpcd/dhcpcd-run-hooks" },
|
||||
{ 00444, AID_RADIO, AID_AUDIO, 0, "system/etc/AudioPara4.csv" },
|
||||
{ 00555, AID_ROOT, AID_ROOT, 0, "system/etc/ppp/*" },
|
||||
|
|
|
@ -1,322 +0,0 @@
|
|||
#!/system/bin/sh
|
||||
|
||||
atdev=/dev/omap_csmi_tty0
|
||||
pppdev=/dev/omap_csmi_tty1
|
||||
|
||||
n1=`cat /data/phoneentry1 2>/dev/null`
|
||||
n2=`cat /data/phoneentry2 2>/dev/null`
|
||||
n3=`cat /data/phoneentry3 2>/dev/null`
|
||||
n1=${n1:-"*#06#"}
|
||||
n2=${n2:-"*#06#"}
|
||||
n3=${n3:-"*#06#"}
|
||||
phoneoutputpid=
|
||||
eventoutputpid=
|
||||
notifypid=
|
||||
notifytoggle=false
|
||||
pppdpid=
|
||||
powerdidletime=120
|
||||
|
||||
# map phone specific keys
|
||||
setkey -k 0xe4 -v 0x23 # map #
|
||||
setkey -k 0xe3 -v 0x2a # map *
|
||||
setkey -k 231 -v 513 # map send to newline
|
||||
#setkey -k 0x67 -v 0x20b # map up to scroll back
|
||||
#setkey -k 0x6c -v 0x20a # map down to scroll forward
|
||||
setkey -k 0x73 -v 0x20b # map volume up to scroll back
|
||||
setkey -k 0x72 -v 0x20a # map volume down to scroll forward
|
||||
setkey -k 0x60 -v 0x211 # map PoC to next console
|
||||
|
||||
# tuttle keys
|
||||
setkey -k 0x38 -v 0x703 # map leftalt to alt
|
||||
setkey -k 0x9b -v 0x703 # map mail to alt
|
||||
setkey -t 8 -k 0x9b -v 0x703 # map alt-mail to alt
|
||||
setkey -t 8 -k 0x10 -v 0x21 # map alt-q to !
|
||||
setkey -t 8 -k 0x11 -v 0x31 # map alt-w to 1
|
||||
setkey -t 8 -k 0x12 -v 0x32 # map alt-e to 2
|
||||
setkey -t 8 -k 0x13 -v 0x33 # map alt-r to 3
|
||||
setkey -t 8 -k 0x14 -v 0x2b # map alt-t to +
|
||||
setkey -t 8 -k 0x15 -v 0x28 # map alt-y to (
|
||||
setkey -t 8 -k 0x16 -v 0x29 # map alt-u to )
|
||||
setkey -t 8 -k 0x17 -v 0x2d # map alt-i to -
|
||||
setkey -t 8 -k 0x18 -v 0x5f # map alt-o to _
|
||||
setkey -t 8 -k 0x19 -v 0x22 # map alt-p to "
|
||||
setkey -t 8 -k 0x1e -v 0x23 # map alt-a to #
|
||||
setkey -t 8 -k 0x1f -v 0x34 # map alt-s to 4
|
||||
setkey -t 8 -k 0x20 -v 0x35 # map alt-d to 5
|
||||
setkey -t 8 -k 0x21 -v 0x36 # map alt-f to 6
|
||||
setkey -t 8 -k 0x22 -v 0x2f # map alt-g to /
|
||||
setkey -t 8 -k 0x23 -v 0x3f # map alt-h to ?
|
||||
setkey -t 8 -k 0x24 -v 0xa3 # map alt-j to pound
|
||||
setkey -t 8 -k 0x25 -v 0x24 # map alt-k to $
|
||||
setkey -t 8 -k 0x2c -v 0x2a # map alt-z to *
|
||||
setkey -t 8 -k 0x2d -v 0x37 # map alt-x to 7
|
||||
setkey -t 8 -k 0x2e -v 0x38 # map alt-c to 8
|
||||
setkey -t 8 -k 0x2f -v 0x39 # map alt-v to 9
|
||||
setkey -t 8 -k 0x30 -v 0x7c # map alt-b to |
|
||||
setkey -t 8 -k 0x31 -v 0x40 # map alt-n to @
|
||||
setkey -t 8 -k 0x32 -v 0x3d # map alt-m to =
|
||||
setkey -t 8 -k 0x33 -v 0x3b # map alt-, to ;
|
||||
setkey -t 8 -k 0x34 -v 0x3a # map alt-. to :
|
||||
setkey -t 8 -k 0x0f -v 0x30 # map alt-tab to 0
|
||||
setkey -t 8 -k 0x67 -v 0x20b # map alt-up to scroll back
|
||||
setkey -t 8 -k 0x6c -v 0x20a # map alt-down to scroll forward
|
||||
|
||||
while true
|
||||
do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: init commands"
|
||||
echo " 2: call commands"
|
||||
echo " 3: misc phone"
|
||||
echo " 4: phone debug output"
|
||||
echo " 5: test data connection"
|
||||
echo " 6: start runtime"
|
||||
echo " 7: start runtime w/output"
|
||||
echo " 8: stop runtime"
|
||||
echo " 9: misc"
|
||||
echo -n ": "
|
||||
while true
|
||||
do
|
||||
c=`readtty -t 50 -f -a 1234567890#`
|
||||
case "$c" in
|
||||
"" ) ;;
|
||||
* ) break;
|
||||
esac
|
||||
done
|
||||
echo Got key -$c-
|
||||
case $c in
|
||||
"1" )
|
||||
while true; do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: Print phone output"
|
||||
echo " 2: ATQ0V1E1+CMEE=2;+CREG=0"
|
||||
echo " 3: AT+CFUN=1"
|
||||
echo " 4: AT+COPS=0"
|
||||
echo " 5: AT+CREG?"
|
||||
echo " 6: Stop phone output"
|
||||
echo " 0: back"
|
||||
echo -n ": "
|
||||
c=`readtty -f -a 1234560#`
|
||||
echo Got key -$c-
|
||||
case "$c" in
|
||||
"1" ) kill $phoneoutputpid; cat $atdev & phoneoutputpid=$! ;;
|
||||
"2" ) echo -e "ATQ0V1E1+CMEE=2;+CREG=0\r" >$atdev;;
|
||||
"3" ) echo -e "AT+CFUN=1\r" >$atdev;;
|
||||
"4" ) echo -e "AT+COPS=0\r" >$atdev;;
|
||||
"5" ) echo -e "AT+CREG?\r" >$atdev;;
|
||||
"6" ) kill $phoneoutputpid; phoneoutputpid= ;;
|
||||
"0" ) break;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
"2" )
|
||||
while true; do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: Dial: ATD $n1;"
|
||||
echo " 2: Dial: ATD $n2;"
|
||||
echo " 3: Dial: ATD $n3;"
|
||||
echo " 4: Set number for 1"
|
||||
echo " 5: Set number for 2"
|
||||
echo " 6: Set number for 3"
|
||||
echo " 7: Dial: ATD ...;"
|
||||
echo " 8: Hang up: ATH"
|
||||
echo " 9: Answer: ATA"
|
||||
echo " 0: back"
|
||||
echo -n ": "
|
||||
c=`readtty -f -a 1234567890#`
|
||||
echo Got key -$c-
|
||||
case "$c" in
|
||||
"1" ) echo "Dialing $n1"; echo -e "ATD $n1;\r" >$atdev;;
|
||||
"2" ) echo "Dialing $n2"; echo -e "ATD $n2;\r" >$atdev;;
|
||||
"3" ) echo "Dialing $n3"; echo -e "ATD $n3;\r" >$atdev;;
|
||||
"4" ) echo -n "Number: "; read n1; echo $n1 >/data/phoneentry1;;
|
||||
"5" ) echo -n "Number: "; read n2; echo $n2 >/data/phoneentry2;;
|
||||
"6" ) echo -n "Number: "; read n3; echo $n3 >/data/phoneentry3;;
|
||||
"7" ) echo -n "Number: "; read n; echo "Dialing $n"; echo -e "ATD $n;\r" >$atdev;;
|
||||
"8" ) echo -e "ATH\r" >$atdev;;
|
||||
"9" ) echo -e "ATA\r" >$atdev;;
|
||||
"0" ) break;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
"3" )
|
||||
while true; do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: Save FFS data"
|
||||
echo " 2: Load user FFS data"
|
||||
echo " 3: Load system FFS data"
|
||||
echo " 4: Reset FFS data"
|
||||
echo " 5: Set uplink gain"
|
||||
echo " 6: Set echo"
|
||||
echo " 7: cat /dev/omap_csmi_battery_t"
|
||||
echo " 8: cat /dev/omap_csmi_htc"
|
||||
echo " 0: back"
|
||||
echo -n ": "
|
||||
c=`readtty -f -a 123456780#`
|
||||
echo Got key -$c-
|
||||
case "$c" in
|
||||
"1" ) cat /dev/omap_csmi_ffs >/data/ffsdata;;
|
||||
"2" ) cat /data/ffsdata >/dev/omap_csmi_ffs;;
|
||||
"3" ) cat /system/ffsdata >/dev/omap_csmi_ffs;;
|
||||
"4" ) echo - >/dev/omap_csmi_ffs;;
|
||||
"5" )
|
||||
echo -n "Gain: "; read g;
|
||||
echo gu$g >/tmp/gain;
|
||||
cat /tmp/gain 2>/dev/null >/dev/omap_csmi_audio_tes
|
||||
;;
|
||||
"6" )
|
||||
echo -n "Echo param (hex): "; read e;
|
||||
echo "e0x$e" >/tmp/echo;
|
||||
cat /tmp/echo 2>/dev/null >/dev/omap_csmi_audio_tes
|
||||
;;
|
||||
"7" ) cat /dev/omap_csmi_battery_t;;
|
||||
"8" ) cat /dev/omap_csmi_htc;;
|
||||
"0" ) break;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
"4" )
|
||||
while true; do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: Toggle debug I/O"
|
||||
echo " 2: Toggle debug Flow"
|
||||
echo " 3: Toggle debug Interrupt"
|
||||
echo " 4: Toggle debug Info"
|
||||
echo " 5: Toggle GSM run state"
|
||||
echo " 6: Clear GSM data area"
|
||||
echo " 0: back"
|
||||
echo -n ": "
|
||||
c=`readtty -f -a 1234560#`
|
||||
echo Got key -$c-
|
||||
case "$c" in
|
||||
"1" ) echo -n "i" >/sys/devices/system/omap_csmi/debug;;
|
||||
"2" ) echo -n "f" >/sys/devices/system/omap_csmi/debug;;
|
||||
"3" ) echo -n "I" >/sys/devices/system/omap_csmi/debug;;
|
||||
"4" ) echo -n "F" >/sys/devices/system/omap_csmi/debug;;
|
||||
"5" ) echo -n "s" >/sys/devices/system/omap_csmi/debug;;
|
||||
"6" ) echo -n "c" >/sys/devices/system/omap_csmi/debug;;
|
||||
"0" ) break;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
"5" )
|
||||
while true; do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: Start pppd - userspace"
|
||||
echo " 2: Start pppd - kernel"
|
||||
echo " 3: Start pppd - kernel <at1"
|
||||
echo " 4: Configure ppp data to at2"
|
||||
echo " 5: Test with HTTP GET"
|
||||
echo " 6: Kill pppd"
|
||||
echo " 0: back"
|
||||
echo -n ": "
|
||||
c=`readtty -f -a 1234560#`
|
||||
echo Got key -$c-
|
||||
case "$c" in
|
||||
"1" ) kill $pppdpid; pppd notty < $pppdev > $pppdev & pppdpid=$!;;
|
||||
"2" ) kill $pppdpid; pppd nodetach $pppdev & pppdpid=$!;;
|
||||
"3" ) kill &pppdpid; pppd nodetach $pppdev connect "sh -c \"chat -v -f /etc/ppp/connect-data <$atdev >$atdev\"" & pppdpid=$!;;
|
||||
"4" ) echo -e 'AT%DATA=2,"UART",1,,"SER","UART",0\r' >$atdev;;
|
||||
"5" ) test-data-connection;;
|
||||
"6" ) kill $pppdpid; pppdpid=;;
|
||||
"0" ) break;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
"6" )
|
||||
echo
|
||||
echo ------------------------
|
||||
echo Starting android runtime
|
||||
echo ------------------------
|
||||
start
|
||||
;;
|
||||
"7" )
|
||||
echo
|
||||
echo ------------------------
|
||||
echo Starting android runtime
|
||||
echo ------------------------
|
||||
if exists /data/singleproc
|
||||
then
|
||||
single_process="-s"
|
||||
else
|
||||
single_process=""
|
||||
fi
|
||||
start runtime $single_process
|
||||
;;
|
||||
"8" )
|
||||
stop
|
||||
;;
|
||||
"9" )
|
||||
while true; do
|
||||
echo
|
||||
echo "------------------------------"
|
||||
echo " 1: Print events"
|
||||
echo " 2: Stop event output"
|
||||
if $notifytoggle
|
||||
then
|
||||
echo " 3: stop notify"
|
||||
else
|
||||
echo " 3: notify /sys/android_power"
|
||||
fi
|
||||
echo " 4: start powerd"
|
||||
echo " 5: start powerd verbose"
|
||||
echo " 6: stop powerd"
|
||||
echo " 7: set powerd idletime ($powerdidletime)"
|
||||
echo " 8: start multitap shell"
|
||||
if exists /data/singleproc
|
||||
then
|
||||
echo " 9: enable multiprocess"
|
||||
else
|
||||
echo " 9: disable multiprocess"
|
||||
fi
|
||||
echo " c: start shell"
|
||||
echo " 0: back"
|
||||
echo -n ": "
|
||||
c=`readtty -f -a 1234567890c#`
|
||||
echo Got key -$c-
|
||||
case "$c" in
|
||||
"1" ) kill $eventoutputpid; getevent & eventoutputpid=$! ;;
|
||||
"2" ) kill $eventoutputpid; eventoutputpid= ;;
|
||||
"3" )
|
||||
if $notifytoggle
|
||||
then
|
||||
kill $notifypid
|
||||
notifypid=
|
||||
notifytoggle=false
|
||||
else
|
||||
kill $notifypid
|
||||
notify -m 0x00000002 -c 0 -p -v 0 -w 30 /sys/android_power &
|
||||
notifypid=$!
|
||||
notifytoggle=true
|
||||
fi
|
||||
;;
|
||||
"4" ) start powerd -i $powerdidletime ;;
|
||||
"5" ) start powerd -i $powerdidletime -v ;;
|
||||
"6" ) stop powerd ;;
|
||||
"7" ) echo -n "Idle time (seconds): "; read powerdidletime ;;
|
||||
"8" )
|
||||
readtty -f -p -t 10 -e "[ ~" | sh -i
|
||||
;;
|
||||
"9" )
|
||||
if exists /data/singleproc
|
||||
then
|
||||
echo "Enabling multiprocess environment."
|
||||
rm /data/singleproc
|
||||
else
|
||||
echo "Disabling multiprocess environment."
|
||||
echo >/data/singleproc "true"
|
||||
fi
|
||||
;;
|
||||
"c" ) sh -i <>/dev/tty0 1>&0 2>&1 ;;
|
||||
"0" ) break;;
|
||||
esac
|
||||
done
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
|
@ -1,183 +0,0 @@
|
|||
#include <ctype.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <sys/mman.h>
|
||||
#include <fcntl.h>
|
||||
#include <string.h>
|
||||
#include <termios.h>
|
||||
#include <unistd.h>
|
||||
|
||||
struct {
|
||||
char key;
|
||||
char *chars;
|
||||
} map[] = {
|
||||
{ '1', "_ -1?!,.:;\"'<=>()_" },
|
||||
{ '2', "Cabc2ABC" },
|
||||
{ '3', "Fdef3DEF" },
|
||||
{ '4', "Ighi4GHI" },
|
||||
{ '5', "Ljkl5JKL" },
|
||||
{ '6', "Omno6MNO" },
|
||||
{ '7', "Spqrs7PQRS" },
|
||||
{ '8', "Vtuv8TUV" },
|
||||
{ '9', "Zwxyz9WXYZ" },
|
||||
{ '0', "*+&0@/#*" },
|
||||
};
|
||||
|
||||
char next_char(char key, char current)
|
||||
{
|
||||
int i;
|
||||
char *next;
|
||||
for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
|
||||
if(key == map[i].key) {
|
||||
next = strchr(map[i].chars, current);
|
||||
if(next && next[1])
|
||||
return next[1];
|
||||
return map[i].chars[1];
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
char prev_char(char key, char current)
|
||||
{
|
||||
int i;
|
||||
char *next;
|
||||
for(i = 0; i < sizeof(map) / sizeof(map[0]); i++) {
|
||||
if(key == map[i].key) {
|
||||
next = strchr(map[i].chars+1, current);
|
||||
if(next && next[-1])
|
||||
return next[-1];
|
||||
return map[i].chars[1];
|
||||
}
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
int readtty_main(int argc, char *argv[])
|
||||
{
|
||||
int c;
|
||||
//int flags;
|
||||
char buf[1];
|
||||
int res;
|
||||
struct termios ttyarg;
|
||||
struct termios savedttyarg;
|
||||
int nonblock = 0;
|
||||
int timeout = 0;
|
||||
int flush = 0;
|
||||
int phone = 0;
|
||||
char *accept = NULL;
|
||||
char *rejectstring = NULL;
|
||||
char last_char_in = 0;
|
||||
char current_char = 0;
|
||||
char *exit_string = NULL;
|
||||
int exit_match = 0;
|
||||
|
||||
do {
|
||||
c = getopt(argc, argv, "nt:fa:r:pe:");
|
||||
if (c == EOF)
|
||||
break;
|
||||
switch (c) {
|
||||
case 't':
|
||||
timeout = atoi(optarg);
|
||||
break;
|
||||
case 'n':
|
||||
nonblock = 1;
|
||||
break;
|
||||
case 'f':
|
||||
flush = 1;
|
||||
break;
|
||||
case 'a':
|
||||
accept = optarg;
|
||||
break;
|
||||
case 'r':
|
||||
rejectstring = optarg;
|
||||
break;
|
||||
case 'p':
|
||||
phone = 1;
|
||||
break;
|
||||
case 'e':
|
||||
exit_string = optarg;
|
||||
break;
|
||||
case '?':
|
||||
fprintf(stderr, "%s: invalid option -%c\n",
|
||||
argv[0], optopt);
|
||||
exit(1);
|
||||
}
|
||||
} while (1);
|
||||
|
||||
if(flush)
|
||||
tcflush(STDIN_FILENO, TCIFLUSH);
|
||||
ioctl(STDIN_FILENO, TCGETS , &savedttyarg) ; /* set changed tty arguments */
|
||||
ttyarg = savedttyarg;
|
||||
ttyarg.c_cc[VMIN] = (timeout > 0 || nonblock) ? 0 : 1; /* minimum of 0 chars */
|
||||
ttyarg.c_cc[VTIME] = timeout; /* wait max 15/10 sec */
|
||||
ttyarg.c_iflag = BRKINT | ICRNL;
|
||||
ttyarg.c_lflag &= ~(ECHO | ICANON);
|
||||
ioctl(STDIN_FILENO, TCSETS , &ttyarg);
|
||||
|
||||
while (1) {
|
||||
res = read(STDIN_FILENO, buf, 1);
|
||||
if(res <= 0) {
|
||||
if(phone) {
|
||||
if(current_char) {
|
||||
write(STDERR_FILENO, ¤t_char, 1);
|
||||
write(STDOUT_FILENO, ¤t_char, 1);
|
||||
if(exit_string && current_char == exit_string[exit_match]) {
|
||||
exit_match++;
|
||||
if(exit_string[exit_match] == '\0')
|
||||
break;
|
||||
}
|
||||
else
|
||||
exit_match = 0;
|
||||
current_char = 0;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if(accept && strchr(accept, buf[0]) == NULL) {
|
||||
if(rejectstring) {
|
||||
write(STDOUT_FILENO, rejectstring, strlen(rejectstring));
|
||||
break;
|
||||
}
|
||||
if(flush)
|
||||
tcflush(STDIN_FILENO, TCIFLUSH);
|
||||
continue;
|
||||
}
|
||||
if(phone) {
|
||||
//if(!isprint(buf[0])) {
|
||||
// fprintf(stderr, "got unprintable character 0x%x\n", buf[0]);
|
||||
//}
|
||||
if(buf[0] == '\0') {
|
||||
if(current_char) {
|
||||
current_char = prev_char(last_char_in, current_char);
|
||||
write(STDERR_FILENO, ¤t_char, 1);
|
||||
write(STDERR_FILENO, "\b", 1);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(current_char && buf[0] != last_char_in) {
|
||||
write(STDERR_FILENO, ¤t_char, 1);
|
||||
write(STDOUT_FILENO, ¤t_char, 1);
|
||||
if(exit_string && current_char == exit_string[exit_match]) {
|
||||
exit_match++;
|
||||
if(exit_string[exit_match] == '\0')
|
||||
break;
|
||||
}
|
||||
else
|
||||
exit_match = 0;
|
||||
current_char = 0;
|
||||
}
|
||||
last_char_in = buf[0];
|
||||
current_char = next_char(last_char_in, current_char);
|
||||
write(STDERR_FILENO, ¤t_char, 1);
|
||||
write(STDERR_FILENO, "\b", 1);
|
||||
continue;
|
||||
}
|
||||
write(STDOUT_FILENO, buf, 1);
|
||||
break;
|
||||
}
|
||||
ioctl(STDIN_FILENO, TCSETS , &savedttyarg) ; /* set changed tty arguments */
|
||||
|
||||
return 0;
|
||||
}
|
Loading…
Reference in a new issue