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

Commit cd6619a6 authored by Michał Brzeziński's avatar Michał Brzeziński Committed by Android (Google) Code Review
Browse files

Merge "Adding corruptionHandler to all usages of DataStore" into main

parents e39501e7 0ebc303c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import androidx.datastore.core.CorruptionException
import androidx.datastore.core.DataStore
import androidx.datastore.core.DataStoreFactory
import androidx.datastore.core.Serializer
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.dataStoreFile
import com.android.framework.protobuf.InvalidProtocolBufferException
import com.android.internal.annotations.VisibleForTesting
@@ -48,6 +49,10 @@ constructor(private val dataStore: DataStore<WindowingEducationProto>) {
        DataStoreFactory.create(
            serializer = WindowingEducationProtoSerializer,
            produceFile = { context.dataStoreFile(APP_HANDLE_EDUCATION_DATASTORE_FILEPATH) },
            corruptionHandler =
                ReplaceFileCorruptionHandler(
                    produceNewData = { WindowingEducationProto.getDefaultInstance() }
                ),
        )
    )

+5 −0
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ import androidx.datastore.core.CorruptionException
import androidx.datastore.core.DataStore
import androidx.datastore.core.DataStoreFactory
import androidx.datastore.core.Serializer
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.dataStoreFile
import com.android.framework.protobuf.InvalidProtocolBufferException
import com.android.internal.annotations.VisibleForTesting
@@ -42,6 +43,10 @@ constructor(private val dataStore: DataStore<WindowingEducationProto>) {
        DataStoreFactory.create(
            serializer = WindowingEducationProtoSerializer,
            produceFile = { context.dataStoreFile(APP_TO_WEB_EDUCATION_DATASTORE_FILEPATH) },
            corruptionHandler =
                ReplaceFileCorruptionHandler(
                    produceNewData = { WindowingEducationProto.getDefaultInstance() }
                ),
        )
    )

+9 −1
Original line number Diff line number Diff line
@@ -24,6 +24,7 @@ import androidx.datastore.core.CorruptionException
import androidx.datastore.core.DataStore
import androidx.datastore.core.DataStoreFactory
import androidx.datastore.core.Serializer
import androidx.datastore.core.handlers.ReplaceFileCorruptionHandler
import androidx.datastore.dataStoreFile
import com.android.framework.protobuf.InvalidProtocolBufferException
import com.android.wm.shell.shared.annotations.ShellBackgroundThread
@@ -49,6 +50,10 @@ class DesktopPersistentRepository(private val dataStore: DataStore<DesktopPersis
            serializer = DesktopPersistentRepositoriesSerializer,
            produceFile = { context.dataStoreFile(DESKTOP_REPOSITORIES_DATASTORE_FILE) },
            scope = bgCoroutineScope,
            corruptionHandler =
                ReplaceFileCorruptionHandler(
                    produceNewData = { DesktopPersistentRepositories.getDefaultInstance() }
                ),
        )
    )

@@ -127,7 +132,10 @@ class DesktopPersistentRepository(private val dataStore: DataStore<DesktopPersis
                    .toBuilder()
                    .putDesktopRepoByUser(
                        userId,
                        currentRepository.toBuilder().putDesktop(desktopId, desktop.build()).build(),
                        currentRepository
                            .toBuilder()
                            .putDesktop(desktopId, desktop.build())
                            .build(),
                    )
                    .build()
            }