diff options
| author | Elliott Hughes <enh@google.com> | 2021-09-08 12:29:33 -0700 |
|---|---|---|
| committer | Elliott Hughes <enh@google.com> | 2021-09-08 12:31:25 -0700 |
| commit | d5ccb038f69193fb63b5169d7adc5da19859c9d8 (patch) | |
| tree | 813dddea915e0a9ea7659d4c678cdf5da248bdb7 /core/java | |
| parent | e34b1b87357e291320e6d307c1762dbab652d23f (diff) | |
Set $TMPDIR as well as java.io.tmpdir.
This helps functions like tmpnam() and tmpfile() to "just work", like
their Java equivalents.
Bug: https://issuetracker.google.com/36991167
Bug: http://b/174682340
Test: atest FrameworksCoreTests:android.app.activity.ActivityThreadTest
Change-Id: Ife785f0ca69a34ba2c6b5d1e8e23f8b883d8fc8f
Diffstat (limited to 'core/java')
| -rw-r--r-- | core/java/android/app/ActivityThread.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java index 41170a4c2749..749e8f548fab 100644 --- a/core/java/android/app/ActivityThread.java +++ b/core/java/android/app/ActivityThread.java @@ -6299,7 +6299,13 @@ public final class ActivityThread extends ClientTransactionHandler { final File cacheDir = context.getCacheDir(); if (cacheDir != null) { // Provide a usable directory for temporary files - System.setProperty("java.io.tmpdir", cacheDir.getAbsolutePath()); + String tmpdir = cacheDir.getAbsolutePath(); + System.setProperty("java.io.tmpdir", tmpdir); + try { + android.system.Os.setenv("TMPDIR", tmpdir, true); + } catch (ErrnoException ex) { + Log.w(TAG, "Unable to initialize $TMPDIR", ex); + } } else { Log.v(TAG, "Unable to initialize \"java.io.tmpdir\" property " + "due to missing cache directory"); |
