Skip to content

Commit

Permalink
Fix serial management in "gnirehtet rt"
Browse files Browse the repository at this point in the history
The command "gnirehtet rt" first checks whether the app is installed on
the device, and installs it if necessary.

However, it didn't forward the serial parameter, so calling "gnirehtet
rt 12345678" failed to install the application on the selected device
when several were plugged.

Therefore, forward the serial to apk_require_installed().
  • Loading branch information
rom1v committed Mar 31, 2017
1 parent ee407b9 commit 7b4e17c
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions gnirehtet
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,10 @@ apk_install() {
}

apk_require_installed() {
local serial="$1"
if [[ ! "$(eval $(adbs "$serial") shell pm list packages com.genymobile.gnirehtet)" ]]
then
apk_install
apk_install "$serial"
# wait a bit after the app is installed so that intent actions are correctly registered
sleep 0.5
fi
Expand All @@ -118,17 +119,8 @@ apk_uninstall() {

start() {
echo 'Starting gnirehtet...'
local dns=
eval set -- $(getopt d: "$@")
while true;
do
case "$1" in
-d) dns="$2"; shift 2;;
--) shift; break;;
*) break;;
esac
done
local serial="$1"
local dns="$2"
evalv $(adbs "$serial") reverse tcp:31416 tcp:31416
[[ $? = 0 ]] || return
local dparam=
Expand All @@ -146,6 +138,20 @@ relay() {
evalv "'$JAVA'" -jar "$(get_relay_path)"
}

parse_start_args() {
dns=
eval set -- $(getopt d: "$@")
while true;
do
case "$1" in
-d) dns="$2"; shift 2;;
--) shift; break;;
*) break;;
esac
done
serial="$1"
}

case "$1" in
install)
shift
Expand All @@ -155,7 +161,8 @@ uninstall)
apk_uninstall "$@";;
start)
shift
start "$@";;
parse_start_args "$@"
start "$serial" "$dns";;
stop)
shift
stop "$@";;
Expand All @@ -164,9 +171,10 @@ relay)
relay "$@";;
rt)
shift
apk_require_installed
parse_start_args "$@"
apk_require_installed "$serial"
trap stop INT
start "$@"
start "$serial" "$dns"
relay;;
*)
syntax;;
Expand Down

0 comments on commit 7b4e17c

Please sign in to comment.