diff --git a/xpcom/base/nsCycleCollector.cpp b/xpcom/base/nsCycleCollector.cpp index 3b88f3cec37b..b0bdc0e71cff 100644 --- a/xpcom/base/nsCycleCollector.cpp +++ b/xpcom/base/nsCycleCollector.cpp @@ -132,9 +132,6 @@ #include #include #endif -#ifdef ANDROID -#include -#endif #ifdef XP_WIN #include @@ -1408,12 +1405,22 @@ private: NS_ConvertUTF16toUTF8(mFilenameIdentifier).get()); // Get the log directory either from $MOZ_CC_LOG_DIRECTORY or from our - // platform's temp directory. + // platform's temp directory. For Android, first try the downloads + // directory which is world-readable rather than the temp directory + // which is not. nsCOMPtr logFile; - if (char* env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) { + char* env; + if (env = PR_GetEnv("MOZ_CC_LOG_DIRECTORY")) { NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, getter_AddRefs(logFile)); - } else { + } +#ifdef ANDROID + if (!logFile && (env = PR_GetEnv("DOWNLOADS_DIRECTORY"))) { + NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, + getter_AddRefs(logFile)); + } +#endif + if (!logFile) { // Ask NSPR to point us to the temp directory. NS_GetSpecialDirectory(NS_OS_TEMP_DIR, getter_AddRefs(logFile)); } @@ -1424,19 +1431,6 @@ private: rv = logFile->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644); NS_ENSURE_SUCCESS(rv, nullptr); -#ifdef ANDROID - { - // On android the default system umask is 0077 which makes these files - // unreadable to the shell user. In order to pull the dumps off a non-rooted - // device we need to chmod them to something world-readable. - // XXX why not logFile->SetPermissions(0644); - nsAutoCString path; - rv = logFile->GetNativePath(path); - if (NS_SUCCEEDED(rv)) { - chmod(path.get(), 0644); - } - } -#endif return logFile.forget(); } diff --git a/xpcom/base/nsMemoryInfoDumper.cpp b/xpcom/base/nsMemoryInfoDumper.cpp index 2604641dc92b..b726095d1aa1 100644 --- a/xpcom/base/nsMemoryInfoDumper.cpp +++ b/xpcom/base/nsMemoryInfoDumper.cpp @@ -739,8 +739,18 @@ MakeFilename(const char *aPrefix, const nsAString &aIdentifier, static nsresult OpenTempFile(const nsACString &aFilename, nsIFile* *aFile) { - nsresult rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile); - NS_ENSURE_SUCCESS(rv, rv); +#ifdef ANDROID + // For Android, first try the downloads directory which is world-readable + // rather than the temp directory which is not. + if (char *env = PR_GetEnv("DOWNLOADS_DIRECTORY")) { + NS_NewNativeLocalFile(nsCString(env), /* followLinks = */ true, aFile); + } +#endif + nsresult rv; + if (!*aFile) { + rv = NS_GetSpecialDirectory(NS_OS_TEMP_DIR, aFile); + NS_ENSURE_SUCCESS(rv, rv); + } nsCOMPtr file(*aFile); @@ -749,19 +759,6 @@ OpenTempFile(const nsACString &aFilename, nsIFile* *aFile) rv = file->CreateUnique(nsIFile::NORMAL_FILE_TYPE, 0644); NS_ENSURE_SUCCESS(rv, rv); -#ifdef ANDROID - { - // On android the default system umask is 0077 which makes these files - // unreadable to the shell user. In order to pull the dumps off a non-rooted - // device we need to chmod them to something world-readable. - // XXX why not logFile->SetPermissions(0644); - nsAutoCString path; - rv = file->GetNativePath(path); - if (NS_SUCCEEDED(rv)) { - chmod(path.get(), 0644); - } - } -#endif return NS_OK; }