Loading core/java/android/util/AtomicFile.java +5 −0 Original line number Diff line number Diff line Loading @@ -330,6 +330,11 @@ public class AtomicFile { } } @Override public String toString() { return "AtomicFile[" + mBaseName + "]"; } private static void rename(File source, File target) { // We used to delete the target file before rename, but that isn't atomic, and the rename() // syscall should atomically replace the target file. However in the case where the target Loading core/tests/utiltests/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ android_test { "frameworks-base-testutils", "mockito-target-minus-junit4", "androidx.test.ext.junit", "truth-prebuilt", ], libs: [ Loading core/tests/utiltests/src/android/util/AtomicFileTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.util; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; Loading Loading @@ -257,6 +259,16 @@ public class AtomicFileTest { } } @Test public void testToString() throws Exception { AtomicFile atomicFile = new AtomicFile(mBaseFile); String toString = atomicFile.toString(); assertThat(toString).contains("AtomicFile"); assertThat(toString).contains(mBaseFile.getAbsolutePath()); } private static void writeBytes(@NonNull File file, @NonNull byte[] bytes) throws IOException { try (FileOutputStream outputStream = new FileOutputStream(file)) { outputStream.write(bytes); Loading Loading
core/java/android/util/AtomicFile.java +5 −0 Original line number Diff line number Diff line Loading @@ -330,6 +330,11 @@ public class AtomicFile { } } @Override public String toString() { return "AtomicFile[" + mBaseName + "]"; } private static void rename(File source, File target) { // We used to delete the target file before rename, but that isn't atomic, and the rename() // syscall should atomically replace the target file. However in the case where the target Loading
core/tests/utiltests/Android.bp +1 −0 Original line number Diff line number Diff line Loading @@ -33,6 +33,7 @@ android_test { "frameworks-base-testutils", "mockito-target-minus-junit4", "androidx.test.ext.junit", "truth-prebuilt", ], libs: [ Loading
core/tests/utiltests/src/android/util/AtomicFileTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package android.util; import static com.google.common.truth.Truth.assertThat; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; Loading Loading @@ -257,6 +259,16 @@ public class AtomicFileTest { } } @Test public void testToString() throws Exception { AtomicFile atomicFile = new AtomicFile(mBaseFile); String toString = atomicFile.toString(); assertThat(toString).contains("AtomicFile"); assertThat(toString).contains(mBaseFile.getAbsolutePath()); } private static void writeBytes(@NonNull File file, @NonNull byte[] bytes) throws IOException { try (FileOutputStream outputStream = new FileOutputStream(file)) { outputStream.write(bytes); Loading