summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorvladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2012-09-19 17:58:01 +0000
committervladlosev <vladlosev@861a406c-534a-0410-8894-cb66d6ee9925>2012-09-19 17:58:01 +0000
commit5d9f11fe81eaca3989ec7e8dbfe5b31608a75121 (patch)
tree1a0e97a3ff6a98ca233732392ae3ccf322df2bdb /src
parentdf246651195747a948cad465dc717133e22973d6 (diff)
downloadgoogletest-5d9f11fe81eaca3989ec7e8dbfe5b31608a75121.tar.gz
Improves Android support (by David Turner).
git-svn-id: http://googletest.googlecode.com/svn/trunk@625 861a406c-534a-0410-8894-cb66d6ee9925
Diffstat (limited to 'src')
-rw-r--r--src/gtest-port.cc22
1 files changed, 18 insertions, 4 deletions
diff --git a/src/gtest-port.cc b/src/gtest-port.cc
index a0e2d7c..9cfe4e9 100644
--- a/src/gtest-port.cc
+++ b/src/gtest-port.cc
@@ -531,11 +531,25 @@ class CapturedStream {
filename_ = temp_file_path;
# else
// There's no guarantee that a test has write access to the current
- // directory, so we create the temporary file in the /tmp directory instead.
- // We use /tmp on most systems, and /mnt/sdcard on Android. That's because
- // Android doesn't have /tmp.
+ // directory, so we create the temporary file in the /tmp directory
+ // instead. We use /tmp on most systems, and /sdcard on Android.
+ // That's because Android doesn't have /tmp.
# if GTEST_OS_LINUX_ANDROID
- char name_template[] = "/mnt/sdcard/gtest_captured_stream.XXXXXX";
+ // Note: Android applications are expected to call the framework's
+ // Context.getExternalStorageDirectory() method through JNI to get
+ // the location of the world-writable SD Card directory. However,
+ // this requires a Context handle, which cannot be retrieved
+ // globally from native code. Doing so also precludes running the
+ // code as part of a regular standalone executable, which doesn't
+ // run in a Dalvik process (e.g. when running it through 'adb shell').
+ //
+ // The location /sdcard is directly accessible from native code
+ // and is the only location (unofficially) supported by the Android
+ // team. It's generally a symlink to the real SD Card mount point
+ // which can be /mnt/sdcard, /mnt/sdcard0, /system/media/sdcard, or
+ // other OEM-customized locations. Never rely on these, and always
+ // use /sdcard.
+ char name_template[] = "/sdcard/gtest_captured_stream.XXXXXX";
# else
char name_template[] = "/tmp/captured_stream.XXXXXX";
# endif // GTEST_OS_LINUX_ANDROID