Skip to content

Commit

Permalink
Enforce save full snapshot when upgrading to 2.4.3 and above.
Browse files Browse the repository at this point in the history
Because snapshot will be saved incrementally, we should trigger at least once full saving to ensure compileSdk and minSdk be recorded.
  • Loading branch information
zhaobozhen committed Dec 4, 2023
1 parent d0ada14 commit 167126b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
Expand Up @@ -5,4 +5,5 @@ object OnceTag {
const val HAS_COLLECT_LIB = "HAS_COLLECT_LIB"
const val HARMONY_FIRST_INIT = "HARMONY_FIRST_INIT"
const val SHOULD_RELOAD_APP_LIST = "1619"
const val SHOULD_SAVE_FULL_SNAPSHOT = "1896"
}
Expand Up @@ -28,6 +28,7 @@ import com.absinthe.libchecker.annotation.RECEIVER
import com.absinthe.libchecker.annotation.SERVICE
import com.absinthe.libchecker.constant.Constants
import com.absinthe.libchecker.constant.GlobalValues
import com.absinthe.libchecker.constant.OnceTag
import com.absinthe.libchecker.data.app.LocalAppDataSource
import com.absinthe.libchecker.database.Repositories
import com.absinthe.libchecker.database.entity.SnapshotItem
Expand All @@ -47,6 +48,7 @@ import java.lang.ref.WeakReference
import java.text.SimpleDateFormat
import java.util.Date
import java.util.Locale
import jonathanfinerty.once.Once
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import timber.log.Timber
Expand Down Expand Up @@ -198,6 +200,7 @@ class ShootService : LifecycleService() {
var lastProgress = 0
var ai: ApplicationInfo
var dbSnapshotItem: SnapshotItem?
val shouldSaveFullSnapshot = !Once.beenDone(Once.THIS_APP_INSTALL, OnceTag.SHOULD_SAVE_FULL_SNAPSHOT)

for (info in appList) {
try {
Expand All @@ -206,7 +209,8 @@ class ShootService : LifecycleService() {

if (dbSnapshotItem?.versionCode == info.getVersionCode() &&
dbSnapshotItem.lastUpdatedTime == info.lastUpdateTime &&
dbSnapshotItem.packageSize == info.getPackageSize(true)
dbSnapshotItem.packageSize == info.getPackageSize(true) &&
!shouldSaveFullSnapshot
) {
Timber.d("computeSnapshots: ${info.packageName} is up to date")
dbList.add(
Expand Down Expand Up @@ -337,6 +341,10 @@ class ShootService : LifecycleService() {
notificationManager.notify(notificationIdShootSuccess, builder.build())
}

if (!Once.beenDone(Once.THIS_APP_INSTALL, OnceTag.SHOULD_SAVE_FULL_SNAPSHOT)) {
Once.markDone(OnceTag.SHOULD_SAVE_FULL_SNAPSHOT)
}

timer.end()
Timber.d("computeSnapshots: $timer")

Expand Down
2 changes: 1 addition & 1 deletion build-logic/src/main/kotlin/Projects.kt
Expand Up @@ -6,7 +6,7 @@ import java.time.Instant
import org.gradle.api.JavaVersion
import org.gradle.api.Project

const val baseVersionName = "2.5.0"
const val baseVersionName = "2.4.4"
val Project.verName: String get() = "${baseVersionName}${versionNameSuffix}.${exec("git rev-parse --short HEAD")}"
val Project.verCode: Int get() = exec("git rev-list --count HEAD").toInt()
val Project.isDevVersion: Boolean get() = exec("git tag -l $baseVersionName").isEmpty()
Expand Down

0 comments on commit 167126b

Please sign in to comment.