Merge "Set $TMPDIR as well as java.io.tmpdir." am: 1353c41379 am: 76aa934468 am: 522439015a am: 08f7be5495
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1821337 Change-Id: Ibe83032e2aec458bad38d327a10b970f05023b5c
This commit is contained in:
@@ -6343,7 +6343,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");
|
||||
|
||||
@@ -107,6 +107,11 @@ public class ActivityThreadTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTemporaryDirectory() throws Exception {
|
||||
assertEquals(System.getProperty("java.io.tmpdir"), System.getenv("TMPDIR"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testDoubleRelaunch() throws Exception {
|
||||
final Activity activity = mActivityTestRule.launchActivity(new Intent());
|
||||
|
||||
Reference in New Issue
Block a user