From 1b296b4749f7f77846ab5cf6f5f05e607b20ec31 Mon Sep 17 00:00:00 2001 From: Victoria Lease Date: Tue, 21 Aug 2012 15:44:06 -0700 Subject: [PATCH] getsdcardpath, getscreenshotpath, getlastscreenshot Added a few new functions to envsetup.sh: - getsdcardpath() returns the sdcard path. This will be more useful when multiuser storage complicates the sdcard path. - getscreenshotpath() returns the path to screenshots - getlastscreenshot() adb pulls the most recently-taken screenshot Change-Id: I851145088344dff6f1672f0a423201f3aa3e4390 --- envsetup.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/envsetup.sh b/envsetup.sh index 701c0f6b2e..4b60c05a2a 100644 --- a/envsetup.sh +++ b/envsetup.sh @@ -979,6 +979,28 @@ function getbugreports() done } +function getsdcardpath() +{ + adb ${adbOptions} shell echo -n \$\{EXTERNAL_STORAGE\} +} + +function getscreenshotpath() +{ + echo "$(getsdcardpath)/Pictures/Screenshots" +} + +function getlastscreenshot() +{ + local screenshot_path=$(getscreenshotpath) + local screenshot=`adb ${adbOptions} ls ${screenshot_path} | grep Screenshot_[0-9-]*.*\.png | sort -rk 3 | cut -d " " -f 4 | head -n 1` + if [ "$screenshot" = "" ]; then + echo "No screenshots found." + return + fi + echo "${screenshot}" + adb ${adbOptions} pull ${screenshot_path}/${screenshot} +} + function startviewserver() { local port=4939