Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 76aa9344 authored by Elliott Hughes's avatar Elliott Hughes Committed by Automerger Merge Worker
Browse files

Merge "Set $TMPDIR as well as java.io.tmpdir." am: 1353c413

Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1821337

Change-Id: Ib98b38571754781102093c67d15ac3364c5dc029
parents 902b8e2d 1353c413
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -6370,7 +6370,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");
+5 −0
Original line number Diff line number Diff line
@@ -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());