-
Notifications
You must be signed in to change notification settings - Fork 2
MS-1457 Auto-capture config #1746
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d5b825
6752b90
2cb5d51
45b876d
25dfdc0
9923ba1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| package com.simprints.infra.config.store.local.migrations | ||
|
|
||
| import androidx.datastore.core.DataMigration | ||
| import com.simprints.infra.config.store.local.models.ProtoProjectConfiguration | ||
| import com.simprints.infra.logging.LoggingConstants.CrashReportTag.MIGRATION | ||
| import com.simprints.infra.logging.Simber | ||
| import com.simprints.infra.serialization.SimJson | ||
| import kotlinx.serialization.SerializationException | ||
| import kotlinx.serialization.json.booleanOrNull | ||
| import kotlinx.serialization.json.jsonObject | ||
| import kotlinx.serialization.json.jsonPrimitive | ||
| import javax.inject.Inject | ||
|
|
||
| /** | ||
| * Can be removed once all the devices have been updated to 2026.3.0 | ||
| */ | ||
| class ProjectConfigFaceAutoCaptureConfigMigration @Inject constructor() : DataMigration<ProtoProjectConfiguration> { | ||
| override suspend fun cleanUp() { | ||
| Simber.i("Migration of face auto-capture flag is complete", tag = MIGRATION) | ||
| } | ||
|
|
||
| override suspend fun shouldMigrate(currentData: ProtoProjectConfiguration) = with(currentData) { | ||
| hasFace() && !face.hasIsAutoCapture() && hasCustomJson() && customJson.contains("faceAutoCaptureEnabled") | ||
| } | ||
|
|
||
| override suspend fun migrate(currentData: ProtoProjectConfiguration): ProtoProjectConfiguration { | ||
| Simber.i("Start migration of face auto-capture flag", tag = MIGRATION) | ||
|
|
||
| val isAutoCapture = try { | ||
| SimJson | ||
| .parseToJsonElement(currentData.customJson) | ||
| .jsonObject["faceAutoCaptureEnabled"] | ||
| ?.jsonPrimitive | ||
| ?.booleanOrNull ?: false | ||
| } catch (e: SerializationException) { | ||
| Simber.e("Failed to parse custom config", e, tag = MIGRATION) | ||
| false | ||
| } | ||
|
luhmirin-s marked this conversation as resolved.
|
||
|
|
||
| return currentData | ||
| .toBuilder() | ||
| .setFace( | ||
| currentData.face | ||
| .toBuilder() | ||
| .setIsAutoCapture(isAutoCapture) | ||
| .build(), | ||
| ).build() | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,13 +21,6 @@ data class ExperimentalProjectConfiguration( | |
| ?.booleanOrNull | ||
| .let { it == true } | ||
|
|
||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @luhmirin-s Just to note that if a user updates to 2026.3.0 and auto-capture was enabled through the custom configuration, the feature will be temporarily disabled until the app syncs the new configuration.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a migration that checks for the stored custom config json and updates the flag in face config so there should not be an interruption. |
||
| val faceAutoCaptureEnabled: Boolean | ||
| get() = customConfig | ||
| ?.get(FACE_AUTO_CAPTURE_ENABLED) | ||
| ?.jsonPrimitive | ||
| ?.booleanOrNull | ||
| .let { it == true } | ||
|
|
||
| val faceAutoCaptureImagingDurationMillis: Long | ||
| get() = customConfig | ||
| ?.get(FACE_AUTO_CAPTURE_IMAGING_DURATION_MILLIS) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This one is useful, please keep.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @alex-vt restored |
||
|
|
@@ -182,7 +175,6 @@ data class ExperimentalProjectConfiguration( | |
|
|
||
| companion object { | ||
| internal const val DISABLE_SUBJECT_POOL_VALIDATION = "disableSubjectPoolValidation" | ||
| internal const val FACE_AUTO_CAPTURE_ENABLED = "faceAutoCaptureEnabled" | ||
| internal const val FACE_AUTO_CAPTURE_IMAGING_DURATION_MILLIS = "faceAutoCaptureImagingDurationMillis" | ||
|
|
||
| internal const val RECORDS_DB_MIGRATION_FROM_REALM_TO_ROOM_ENABLED = "recordsDbMigrationFromRealmEnabled" | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.