Loading packages/SystemUI/src/com/android/systemui/bubbles/storage/BubblePersistentRepository.kt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ class BubblePersistentRepository @Inject constructor( fun readFromDisk(): List<BubbleEntity> { fun readFromDisk(): List<BubbleEntity> { synchronized(bubbleFile) { synchronized(bubbleFile) { if (!bubbleFile.exists()) return emptyList() try { return bubbleFile.openRead().use(::readXml) } catch (e: Throwable) { try { return bubbleFile.openRead().use(::readXml) } catch (e: Throwable) { Log.e(TAG, "Failed to open bubble file", e) Log.e(TAG, "Failed to open bubble file", e) } } Loading packages/SystemUI/tests/src/com/android/systemui/bubbles/storage/BubblePersistentRepositoryTest.kt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import junit.framework.Assert.assertEquals import junit.framework.Assert.assertEquals import junit.framework.Assert.assertNotNull import junit.framework.Assert.assertTrue import org.junit.Before import org.junit.Before import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith Loading @@ -42,6 +44,11 @@ class BubblePersistentRepositoryTest : SysuiTestCase() { @Test @Test fun testReadWriteOperation() { fun testReadWriteOperation() { // Verify read before write doesn't cause FileNotFoundException val actual = repository.readFromDisk() assertNotNull(actual) assertTrue(actual.isEmpty()) repository.persistsToDisk(bubbles) repository.persistsToDisk(bubbles) assertEquals(bubbles, repository.readFromDisk()) assertEquals(bubbles, repository.readFromDisk()) } } Loading Loading
packages/SystemUI/src/com/android/systemui/bubbles/storage/BubblePersistentRepository.kt +1 −0 Original line number Original line Diff line number Diff line Loading @@ -54,6 +54,7 @@ class BubblePersistentRepository @Inject constructor( fun readFromDisk(): List<BubbleEntity> { fun readFromDisk(): List<BubbleEntity> { synchronized(bubbleFile) { synchronized(bubbleFile) { if (!bubbleFile.exists()) return emptyList() try { return bubbleFile.openRead().use(::readXml) } catch (e: Throwable) { try { return bubbleFile.openRead().use(::readXml) } catch (e: Throwable) { Log.e(TAG, "Failed to open bubble file", e) Log.e(TAG, "Failed to open bubble file", e) } } Loading
packages/SystemUI/tests/src/com/android/systemui/bubbles/storage/BubblePersistentRepositoryTest.kt +7 −0 Original line number Original line Diff line number Diff line Loading @@ -20,6 +20,8 @@ import android.testing.AndroidTestingRunner import androidx.test.filters.SmallTest import androidx.test.filters.SmallTest import com.android.systemui.SysuiTestCase import com.android.systemui.SysuiTestCase import junit.framework.Assert.assertEquals import junit.framework.Assert.assertEquals import junit.framework.Assert.assertNotNull import junit.framework.Assert.assertTrue import org.junit.Before import org.junit.Before import org.junit.Test import org.junit.Test import org.junit.runner.RunWith import org.junit.runner.RunWith Loading @@ -42,6 +44,11 @@ class BubblePersistentRepositoryTest : SysuiTestCase() { @Test @Test fun testReadWriteOperation() { fun testReadWriteOperation() { // Verify read before write doesn't cause FileNotFoundException val actual = repository.readFromDisk() assertNotNull(actual) assertTrue(actual.isEmpty()) repository.persistsToDisk(bubbles) repository.persistsToDisk(bubbles) assertEquals(bubbles, repository.readFromDisk()) assertEquals(bubbles, repository.readFromDisk()) } } Loading